XAML StringFormat to format a Double value

c#, wpf, xaml

Solution

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

Problem

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

Original source