Reputation: 50038
I want to format my slider value to be 00:00 format. The below code worked for me, but what I wanted is 00:00 format. I am looking for a total XAML solution. I know that I can write a converter for this easily but wonder if there are any StringFormat way to make it.
Text="{Binding Value, ElementName=slider,StringFormat=\{0:00.00\}}"
My question here is how can I get colon ':' instead of dot '.' ?
Upvotes: 6
Views: 15811
Reputation: 4218
If you just want to put a :
symbol in the format string, then you escape it with backslashes:
Text="{Binding Value, ElementName=slider,StringFormat=\{0:00\\:00\}}"
But I think this is what you want to do:
<Slider Name="slider" Width="500" Height="30" Maximum="100" Minimum="0" />
<TextBlock Text="{Binding Path=Value, ElementName=slider, StringFormat={}{0:00\\:00}}" />
Upvotes: 11
Reputation: 3611
I don't think there's a real solution to this but if you can multiply your slider values by 100 you can just use 00:00 as your format string.
Upvotes: 2
Reputation: 805
You can use the default String formatting options in the StringFormat as in regular C# code. Have a look at this page, you'll probably find what you need.
Upvotes: 2