WPF MenuItem IsChecked Binding not working
Posted
by Kaya
on Stack Overflow
See other posts from Stack Overflow
or by Kaya
Published on 2010-05-25T12:42:35Z
Indexed on
2010/05/25
18:41 UTC
Read the original article
Hit count: 1304
Anyone know why the menu item binding does not work ?
<ToggleButton Name="toggleButton" Checked="checkBoxPublish_Checked" >
<ToggleButton.Resources>
<converters:BooleanToHiddenVisibility x:Key="boolToVis"/>
</ToggleButton.Resources>
<Grid>
<Image Height="auto" HorizontalAlignment="Left" Margin="5" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="auto" />
<Viewbox >
<TextBlock Text="Blocked" Opacity="0.7" Foreground="Red" Visibility="{Binding Path=IsChecked, ElementName=toggleButton, Converter={StaticResource boolToVis}}"/>
</Viewbox>
</Grid>
<ToggleButton.ContextMenu>
<ContextMenu StaysOpen="True" >
<MenuItem x:Name="menuItemBlock" Header="Block" Click="menuItemClick" IsCheckable="True" IsChecked="{Binding ElementName=toggleButton, Path=IsChecked}"/>
<MenuItem x:Name="menuItemIgnorePtz" Header="Ignore Ptz" Click="menuItemClick" IsCheckable="True" />
</ContextMenu>
</ToggleButton.ContextMenu>
</ToggleButton>
© Stack Overflow or respective owner