I did the basic data binding in the code behind, this is the code:
Binding bindingSlider = new Binding();
bindingSlider.Source = mediaElement.Position;
bindingSlider.Mode = BindingMode.TwoWay;
bindingSlider.Converter = (IValueConverter)Application.Current.Resources["DoubleTimeSpan"];
slider.SetBinding(Slider.ValueProperty, bindingSlider);
And this is the converter code,
class DoubleTimeSpan : IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
string language)
{
return ((TimeSpan)value).TotalSeconds;
}
public object ConvertBack(object value, Type targetType, object parameter,
string language)
{
return TimeSpan.FromSeconds((double)value);
}
}
Even if I do not receive a compiler error message, but the binding code does not work. Why?
Herks source
share