There are some StringFormat options working here - but if you want to have total freedom of TimeSpan to string conversion, while remaining well within clean XAML style, there is also the option of creating a simple IValueConverter :
using System;
using System.Windows.Data;
namespace Bla
{
[System.Windows.Data.ValueConversion(typeof(TimeSpan), typeof(string))]
public class TimespanToSpecialStringConverter : IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
if (targetType != typeof(string))
throw new InvalidOperationException("The target must be a string");
var timeSpan = (TimeSpan)value;
string minutes = timeSpan.Minutes < 10 ? "0" + timeSpan.Minutes : ""+timeSpan.Minutes;
string seconds = timeSpan.Seconds < 10 ? "0" + timeSpan.Seconds : "" + timeSpan.Seconds;
return "" + timeSpan.TotalHours + ":" + minutes + ":" + seconds;
}
public object ConvertBack(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
if (targetType != typeof(TimeSpan))
throw new InvalidOperationException("The target must be a TimeSpan");
return TimeSpan.Zero;
}
#endregion
}
}
then, its possible to have, for example a StaticResource in a user control :
<UserControl.Resources>
<local:TimespanToSpecialStringConverter x:Key="TimespanToSpecialStringConverter" />
</UserControl.Resources>
and finally apply the TimespanToSpecialStringConverter within a typical databinding :
<TextBlock Text="{Binding Path=ATimespanDependencyProperty, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource TimespanToSpecialStringConverter}}" />
Now you can programatically change the string conversion to your needs while having clean XAML :) Remember, this is only another option if you need full flexibility.
PS: Now I have read, that you were already using a Converter. So this answer does not 100% fit to the question about what 'other' alternatives are possible. However, I hope it is left here, since many people might find this a usefull way to go.