Just ran into this problem for UWP while creating StringFormatConverter ConverterParameter for TimeSpan value. The custom format string TimeSpan.ToString (x), for some crazy reason, requires apostrophes around alphabetic characters, although DateTimeOffset does not. Seems overly controversial.
In any case ... None of the above worked successfully. One approach worked to get the XAML designer to display / work, but he created a build error.
The solution I settled on was to put the format string in the string resource of the nearest enclosing element. Since I displayed the value in a field created using Border, I inserted a format string into the resources of the Border element.
StringFormatConverter is a Microsoft UWP toolkit on NuGet.
<StackPanel Orientation="Horizontal"> <TextBlock Text="Timespan=" /> <Border BorderBrush="Black" BorderThickness="0.5" Padding="2"> <Border.Resources> <x:String x:Key="TimespanValueConverterParameter">{0:hh':'mm':'ss'.'fff}</x:String> </Border.Resources> <TextBlock Text="{Binding TimespanValue, Mode=OneWay, Converter={StaticResource StringFormatConverter}, ConverterParameter={StaticResource TimespanValueConverterParameter}}" /> </Border> </StackPanel>
kburgoyne
source share