I want to be able to show minutes and seconds in a textbox. The TextBox
is bound towards a property, which is a TimeSpan
. In the textbox, the default is : "00:00:00".
This works fine, but how to show only 00:00 where the hours portion is removed.
How do I do this?
This is my binding:
public TimeSpan MaxTime
{
get
{
if (this.Examination.MaxTime == 0)
return TimeSpan.Zero;
else
return maxTime;
}
set
{
maxTime = value;
OnPropertyChanged("MaxTime");
TimeSpan x;
this.Examination.MaxTime = int.Parse(maxTime.TotalSeconds.ToString());
}
}
<TextBox Text="{Binding Path=MaxTime,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"/>
{0:hh':'mm}
, that is:<TextBlock Text="{Binding MaxTime, StringFormat={}{0:hh':'mm}}" />
– Usurpation