Binding between Slider and Line not working

njsokalski

Well-known member
Joined
Mar 16, 2011
Messages
102
Programming Experience
5-10
I have the following two elements on my page:

<Line Grid.Column="6" Grid.Row="1" Grid.RowSpan="2" I****TestVisible="False" Stroke="Red" StrokeEndLineCap="Round" StrokeStartLineCap="Round" X1="15" X2="105" Y1="105" Y2="15" StrokeThickness="{Binding ElementName=sldLineWidth,Path=Value,Mode=TwoWay}"/>

<Slider Name="sldLineWidth" Grid.Column="3" Grid.Row="3" Grid.ColumnSpan="4" Minimum="1" Maximum="15" SmallChange="1" LargeChange="1" Value="15" VerticalAlignment="Center" Template="{StaticResource ValueSliderTemplate}"/>

As you can see, I am attempting to use binding between the Line's StrokeThickness property and the Slider's Value property. In Design View in Visual Studio 2010, the Line changes size when I change the Value property in the Slider, but not when I attempt to run the debugger. When I run the debugger, the Slider is displayed with the correct Value and I am able to slide it, but the Line is displayed with a StrokeThickness of 1, regardless of what the Value property of the Slider is set to or where I slide the Slider to. The Value and StrokeThickness properties are both DependencyProperty's and have values of type Double, so why is Visual Studio 2010's Design View showing the binding but not the emulator? Any help would be appreciated. Thanks.
 
Top Bottom