MS BI

Microsoft SQL Server Business Intelligence

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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>

posted on 2010-06-17 15:55  Jiger  阅读(466)  评论(0编辑  收藏  举报