Binding the value of a slider to a double Property raises exception

Topics: Bugs, Conventions
May 8, 2013 at 8:05 AM
I have a slider Control on my WP7 Page defined like this:
                    <Slider x:Name="VideoLength"
                            Value="{Binding VideoLength, Mode=TwoWay}"
                            Grid.Column="0" />
In my ViewModel I have a property defined like this:
    public double VideoLength
            return this.settings.VideoLength;
            this.settings.VideoLength = (int)value;
            this.NotifyOfPropertyChange(() => this.VideoLength);
Binding works because the value is updated but I get this exception:

A first chance exception of type 'System.InvalidOperationException' occurred in
System.Windows.Data Error: 'MS.Internal.Data.DynamicValueConverter' converter failed to convert value '7' (type 'System.Double'); BindingExpression: Path='VideoLength' DataItem='HiddenCamera.ViewModels.SettingsPageViewModel' (HashCode=60679928); target element is 'System.Windows.Controls.Slider' (Name='VideoLength'); target property is 'Visibility' (type 'System.Windows.Visibility').. System.InvalidOperationException: Can't convert type System.Double to type System.Windows.Visibility.
at MS.Internal.Data.DefaultValueConverter.Create(Type sourceType, Type targetType, Boolean targetToSource)
at MS.Internal.Data.DynamicValueConverter.EnsureConverter(Type sourceType, Type targetType)
at MS.Internal.Data.DynamicValueConverter.Convert(Object value, Type targetType, Object parameter, CultureInfo culture)
at System.Windows.Data.BindingExpression.ConvertToTarget(Object value).

I have no other binding conventions defined so I don't know why Caliburn tries to bind to System.Windows.Visibility.
My caliburn micro version is (added to the project with nuget)
May 9, 2013 at 5:32 AM
Its probably freaking cause you technically are telling Caliburn to bind the control twice... once with x:Name=VideoLength and secondly with Value={Binding xxx}, so I am not surprised its dying it doesn't know which to do..

Choose one that works for you and roll with it. There should be a default convention for slider already in the framework for wp7/8 so, you need to choose which way you want it either Value or run with the convention.
May 12, 2013 at 11:18 AM
It looks like the default convention is trying to bind VideoLength to Visibility. Remove the x:Name binding and it should work.
May 12, 2013 at 6:21 PM
You were right, removing the default binding solved the problem. I did not expect a binding to Visibility. Thank you.