问题
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},\ '}" />
with this you can also add CR and LF (\ \).
来源:https://stackoverflow.com/questions/39470410/space-in-stringformat