I have a custom media player object that I create in code behind from a user control. There can be 1 to 4 of these at any time, but i want to bind the volume and the mute property of only one to a xaml control EG.
The control is:
MediaControlplayer vcMediaPlayerMaster = new MediaControlplayer();
In this case the mute option to the ischecked
state of the control does not work. How can I hook the binding up to the properties of the control when it is instantiated in code behind ?
xaml is like this. The variable vcMediaPlayerMaster is a global variable in code behind. When i instantiated it i assumed its declaration as a global predefined variable would allow the xaml below to bind to it, but it seems not to be the case.
<ToggleButton x:Name="btnAudioToggle" ToolTip="Audio Mute/Unmute"
Click="BtnAudioToggle_OnClick" IsChecked="{Binding Mode =TwoWay,
ElementName=vcMediaPlayerMaster, Path=Mute}" BorderBrush="LightBlue"
Width="32" Height="32" Margin="0,5,10,10" Background="{StaticResource
IbAudio}" Style="{DynamicResource ToggleButtonStyle1}" > </ToggleButton>
I thought perhaps creating a binding in code behind may be the way to go, but i cant seem to find a simple example that explains the code behind process to do that to fit my case.