Space in StringFormat

拥有回忆 提交于 2020-02-02 03:02:07

问题


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:\,}\,}" />

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.


回答1:


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}\, '}" />



回答2:


Try this:

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

with this you can also add CR and LF (\&#x10; \&#x13;).



来源:https://stackoverflow.com/questions/39470410/space-in-stringformat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!