Sid Price
asked on
WPF - External data binding to controls inside a UserControl
In my project I am developing a UserControl that has a slider and some other controls inside it. I need to data bind to some of these controls, for example the Minimum, Maximum, and Value of the slider control. As an initial step I have created a Dependency Property on the UserControl for the "Value" property of the slider, it is called "Volume."
The UserControl has this binding for the slider value property:
The user control is used on the main form of the application and I attempted to data bind the volume property like this:
However, when I use the slider the "MasterVolume" property is not being updated.
Any input would be greatly appreciated,
Sid
Public Shared ReadOnly volumeProperty As DependencyProperty = DependencyProperty.Register("volume", GetType(Double), GetType(CA_Fader))
Public Property volume As Double
Get
Return CDbl(GetValue(volumeProperty))
End Get
Set(value As Double)
SetValue(volumeProperty, value)
End Set
End Property
The UserControl has this binding for the slider value property:
<Slider x:Name="slider" Value="{Binding volume, Mode=TwoWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" Orientation="Vertical" Maximum="1" LargeChange="0.1" SmallChange="0.01" Width="30" Margin="11,4,0,3"/>
The user control is used on the main form of the application and I attempted to data bind the volume property like this:
<local:CA_Fader x:Name="slider2" volume="{Binding CuePlayManager.TheMixer.MasterVolume}" Height="140" Width="74" Margin="0,2"/>
However, when I use the slider the "MasterVolume" property is not being updated.
Any input would be greatly appreciated,
Sid
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER