Quantcast
Viewing all articles
Browse latest Browse all 18858

StringFormat XAML add dashes to string value

Is it possible to format a number like 123456789000 to 123-456-789-000 using stringformat in xaml (wpf)? It seems most examples I see are for formatting dates and numbers, not strings. Here are some things I have tried but they do not format the value:

<Label  Content="{Binding DataContext.ID, StringFormat={}{0:###-###-###-###}}"></Label>
<Label  Content="{Binding DataContext.ID, StringFormat=000-000-000-000}"></Label>
<Label  Content="{Binding DataContext.ID, StringFormat={}{0:000-000-000-000}}"></Label>

I'm not clear on the syntax for this type of formatting (why sometimes you start with {} and if I should use 0 or # or something else to represent digits.)

Thanks



Viewing all articles
Browse latest Browse all 18858

Trending Articles