Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 879
CBreeze Avatar asked Sep 13 '16 12:09

CBreeze


2 Answers

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}\, '}" />
like image 118
Gusdor Avatar answered Nov 03 '22 05:11

Gusdor


Try this:

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

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

like image 44
WPFGermany Avatar answered Nov 03 '22 04:11

WPFGermany