tags:

views:

714

answers:

4

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 '.' ?

A: 

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.

thanks, but I know that I can use any of the String format expressions.. But coudlnt get a solution for colon ':' Since double value formatting is expecting a dot '.' somewhere.
Jobi Joy
A: 

For anyone whos's looking for binding syntax for numbers and etc, you can check it on

this msdn site

Junior Mayhé
+1  A: 

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.

Alan Mendelevich
+1  A: 

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}}" />
Nate Zaugg