wpf/silverlight中,如果一个控件定义有邮件菜单,而当控件的disabled=true时,默认情况下,系统禁止弹出右键菜单,这时可以使用如下方法弹出,
<Window x:Class="HDI_WPF_ContextMenu_cs.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<TextBox x:Name="txtInput"
IsEnabled="False"
ContextMenuService.ShowOnDisabled="True"
Height="23" Width="200" Background="LightBlue" VerticalAlignment="Top" Margin="50">
<TextBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Menu Item 1" Click="MenuItem_Click" />
<MenuItem Header="Menu Item 2" IsCheckable="True" IsChecked="True" />
<MenuItem Header="Menu Item 3" Click="MenuItem_Click_1"/>
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
</Grid>
</Window>