代码启用WPF为文本菜单左键:禁用右键单击使用MVVM
<Button Style="{StaticResource HPForegroundStyle}" IsTabStop="False"
Command="{Binding ForegroundPhoneCommand}" Click="Button_Click">
<Button.ContextMenu>
<ContextMenu ItemsSource="{Binding OptionsMenuItemList}" ItemContainerStyle="{StaticResource ContextMenuItemStyle}"
IsOpen="{Binding IsMenuOpen}"
PlacementTarget="{Binding RelativeSourc={RelativeSource AncestorType={x:Type Button}}}">
</ContextMenu>
</Button.ContextMenu>
</Button>
我使用MVVM模式。在ViewModel我有一个属性'IsMenuOpen',它控制上下文菜单打开关闭。问题是,我可以禁用右键点击,并不能左键单击显示上下文菜单。
如何打开上下文菜单?它是一个弹出式菜单或实际的上下文菜单控制 – TerrorAustralis 2010-10-27 05:53:34
其上下文菜单 – suman 2010-10-27 06:13:04
当你右键点击,它不会打开,但左键点击并不打开它吗? ForegroundPhoneCommand是否会将IsMenuOpen属性设置为true?并且IsMenuOpen属性是否实现INotifyPropertyChange – TerrorAustralis 2010-10-27 06:17:37