码迷,mamicode.com
首页 > 其他好文 > 详细

D25_01_菜单(menu ContextMenu)

时间:2014-11-02 17:51:11      阅读:255      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   color   ar   os   sp   div   

bubuko.com,布布扣

 

<Window x:Class="demo.MixedMenus"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MixedMenus" Height="350" Width="525">
    <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        
        <StackPanel>
            <!--Menu菜单-->
            <Menu VerticalAlignment="Top" IsMainMenu="True">
                <MenuItem Header="File">
                    <MenuItem Header="Open"></MenuItem>
                </MenuItem>
            </Menu>
            <Button Padding="3" Margin="5">An Ordinary Button</Button>
        </StackPanel>
        <TextBox Grid.Row="1" Margin="5" Name="txt1">
            <TextBox.Text>A TextBox</TextBox.Text>
            <!--ContextMenu菜单-->
            <TextBox.ContextMenu>
                <ContextMenu>
                    <!--ClearText事件处理方法-->
                    <MenuItem Header="ClearText" Click="ClearText"></MenuItem>
                    <MenuItem Header="Close"></MenuItem>
                </ContextMenu>
            </TextBox.ContextMenu>
        </TextBox>
        
        <StackPanel Grid.Row="1" Grid.Column="1">
            <CheckBox Margin="5">A CheckBox</CheckBox>
            <Menu VerticalAlignment="Top">
                <MenuItem Header="File"></MenuItem>
                <MenuItem Header="Help"></MenuItem>
            </Menu>
        </StackPanel>
        
        <Menu Grid.Row="3" Margin="5" VerticalAlignment="top" HorizontalAlignment="Left">
            <MenuItem Header="File">
                <!--IsCheckable:点过后通过对号记录是否点击过-->
                <MenuItem Header="New" IsCheckable="True"></MenuItem>
                <MenuItem Header="Open" Click="MenuItem_Click" IsCheckable="True"></MenuItem>
                <MenuItem Header="Save"></MenuItem>
            </MenuItem>
        </Menu>
    </Grid>
</Window>

 

bubuko.com,布布扣bubuko.com,布布扣

<Window x:Class="demo.SideBarMenu"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="SideBarMenu" Height="326.4" Width="456.8">
    <DockPanel LastChildFill="True" Margin="5">
        <Border BorderBrush="SteelBlue" BorderThickness="1">
            <ScrollViewer DockPanel.Dock="Left">
                <Menu>
                    <Menu.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Background="White"></StackPanel>
                        </ItemsPanelTemplate>
                    </Menu.ItemsPanel>
                    
                    <MenuItem Header="File">
                        <MenuItem Header="New"></MenuItem>
                        <MenuItem Header="Open"></MenuItem>
                        <MenuItem Header="Save"></MenuItem>
                    </MenuItem>
                    <MenuItem Header="Help"></MenuItem>
                </Menu>
            </ScrollViewer>
        </Border>
        
        <TextBox Margin="5,0,0,0" TextWrapping="Wrap">Other content goes here.</TextBox>
    </DockPanel>
</Window>

 

bubuko.com,布布扣bubuko.com,布布扣

 

<Window x:Class="demo.MenuWithSubHeading"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MenuWithSubHeading" Height="300" Width="300">
    <Grid>
        <Grid.RowDefinitions >
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <Menu>
            <MenuItem Header="File">
                <MenuItem Header="New"></MenuItem>
                <MenuItem Header="Open"></MenuItem>
                <MenuItem Header="Save"></MenuItem>
                <Separator></Separator>
                <MenuItem Header="Exit"></MenuItem>
            </MenuItem>
            <MenuItem Header="Edit">
                <MenuItem Header="Undo"></MenuItem>
                <MenuItem Header="Redo"></MenuItem>
                <Separator>
                    <Separator.Template>
                        <ControlTemplate>
                            <Border CornerRadius="2" Padding="5" BorderBrush="Black" BorderThickness="1" Background="PaleGoldenrod">
                                <TextBlock FontWeight="Bold">
                                    Editing Commands
                                </TextBlock>
                            </Border>
                        </ControlTemplate>
                    </Separator.Template>
                </Separator>
                <MenuItem Header="Cut"></MenuItem>
                <MenuItem Header="Copy"></MenuItem>
                <MenuItem Header="Paste"></MenuItem>
            </MenuItem>
        </Menu>
    </Grid>
</Window>

D25_01_菜单(menu ContextMenu)

标签:style   blog   http   io   color   ar   os   sp   div   

原文地址:http://www.cnblogs.com/xiepengtest/p/4069507.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!