I am not an expert in TimeSpan
formatting, so I canβt say exactly why they give the same result, but you can read about it here: Custom TimeSpan format strings
Of course, each of them does not work on the other.
They work the same way, the only thing is that you should use the single backslash in double quotes. Following
<Binding Path="MinTime" StringFormat="hh\\:mm\\:ss" TargetNullValue=" --- "/>
goes to hh\\\\:mm\\\\:ss
. So instead you should write
<Binding Path="MinTime" StringFormat="hh\:mm\:ss" TargetNullValue=" --- "/>
The next two Bindings
should give the same result.
<DataGridTextColumn Header="Max Time" IsReadOnly="True" Binding="{Binding Path=MaxTime, StringFormat=hh\\:mm\\:ss, TargetNullValue=' --- '}"/> <DataGridTextColumn Header="Min Time" IsReadOnly="True"> <DataGridTextColumn.Binding> <Binding Path="MinTime" StringFormat="hh\:mm\:ss" TargetNullValue=" --- "/> </DataGridTextColumn.Binding> </DataGridTextColumn>
And so should the next two
<DataGridTextColumn Header="Max Time" IsReadOnly="True" Binding="{Binding Path=MaxTime, StringFormat={}{0:hh':'mm':'ss}, TargetNullValue=' --- '}"/> <DataGridTextColumn Header="Min Time" IsReadOnly="True"> <DataGridTextColumn.Binding> <Binding Path="MinTime" StringFormat="{}{0:hh':'mm':'ss}" TargetNullValue=" --- "/> </DataGridTextColumn.Binding> </DataGridTextColumn>
source share