StringFormat 中的空格 [英] Space in StringFormat

查看:50
本文介绍了StringFormat 中的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在绑定后添加一个逗号和一个空格".我在绑定后有逗号,但我根本不知道如何做一个空格".这就是我所拥有的;

I'm looking to add a comma and one 'space' after a binding. I have the comma after the binding but I cannot work out at all how to do a 'space'. This is what I have;

<TextBlock Text="{Binding Name, StringFormat={}{0:\,}\,}" />

有人可以告诉我如何在逗号后添加空格"吗?我曾尝试在 XAML 中逐字添加一个空格,但这不起作用.

Could someone please inform me on how to add a 'space' after the comma? I have tried literally adding a space in the XAML but this does not work.

推荐答案

XAML 会修剪空白字符串,除非您告诉它字符串的结束位置.用单引号将字符串括起来.

XAML trims the string of whitespace unless you tell it where the string ends. Surround your string with single quotes.

<TextBlock Text="{Binding Name, StringFormat='{}{0}\, '}" />

这篇关于StringFormat 中的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆