Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| <Canvas | |
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
| x:Class="ContextMenus.Pane1" | |
| Name="cv1" | |
| > | |
| <Grid Name="grid" ShowGridLines ="false" Background ="White" > | |
| <Grid.ColumnDefinitions> | |
| <ColumnDefinition Width="300"/> | |
| <ColumnDefinition Width="250"/> | |
| </Grid.ColumnDefinitions> | |
| <Grid.RowDefinitions> | |
| <RowDefinition/> | |
| <RowDefinition/> | |
| <RowDefinition/> | |
| <RowDefinition/> | |
| <RowDefinition/> | |
| <RowDefinition/> | |
| <RowDefinition/> | |
| <RowDefinition/> | |
| <RowDefinition/> | |
| <RowDefinition/> | |
| <RowDefinition/> | |
| <RowDefinition/> | |
| <RowDefinition/> | |
| </Grid.RowDefinitions> | |
| <TextBlock Margin="10, 10, 0, 0" Grid.Column="0" Grid.Row="0" FontSize="24"> | |
| Context Menus | |
| </TextBlock> | |
| <TextBlock Margin="10, 10, 0, 0" Grid.Column="0" Grid.Row="1" FontSize="14" Grid.ColumnSpan="2"> | |
| The following context menu examples demonstrate: | |
| </TextBlock> | |
| <DockPanel Margin="10, 10, 0, 0" Grid.Column="0" Grid.Row="2"> | |
| <!--<Snippet1>--> | |
| <Button Name="cmButton" Height="30"> | |
| Button with Context Menu | |
| <Button.ContextMenu> | |
| <!--<SnippetContextMenuEvents>--> | |
| <ContextMenu Name="cm" Opened="OnOpened" Closed="OnClosed" StaysOpen="true"> | |
| <!--</SnippetContextMenuEvents>--> | |
| <MenuItem Header="File"/> | |
| <MenuItem Header="Save"/> | |
| <MenuItem Header="SaveAs"/> | |
| <MenuItem Header="Recent Files"> | |
| <MenuItem Header="ReadMe.txt"/> | |
| <MenuItem Header="Schedule.xls"/> | |
| </MenuItem> | |
| </ContextMenu> | |
| </Button.ContextMenu> | |
| </Button> | |
| <!--</Snippet1>--> | |
| </DockPanel> | |
| <TextBlock Margin="10, 10, 5, 5" Grid.Column="1" Grid.Row="2" FontSize="12" | |
| TextWrapping="WrapWithOverflow" VerticalAlignment="Center"> | |
| Simple context menu with submenu items. Also illustrates the Opened | |
| and Closed events. | |
| </TextBlock> | |
| <DockPanel Margin="10, 10, 0, 0" Grid.Column="0" Grid.Row="3"> | |
| <Button Height="30"> | |
| With ToolTip | |
| <Button.ContextMenu> | |
| <!--<SnippetContextMenuProps>--> | |
| <ContextMenu HorizontalOffset="50" VerticalOffset="50" HasDropShadow="false"> | |
| <!--</SnippetContextMenuProps>--> | |
| <MenuItem Header="Edit"> | |
| <MenuItem Header="Cut"/> | |
| <MenuItem Header="Copy"/> | |
| <MenuItem Header="Paste"/> | |
| <Separator/> | |
| <MenuItem Header="Context Menu item with ToolTip"> | |
| <MenuItem.ToolTip> | |
| <ToolTip> | |
| Some information. | |
| </ToolTip> | |
| </MenuItem.ToolTip> | |
| </MenuItem> | |
| </MenuItem> | |
| </ContextMenu> | |
| </Button.ContextMenu> | |
| </Button> | |
| </DockPanel> | |
| <TextBlock Margin="10, 10, 5, 5" Grid.Column="1" Grid.Row="3" FontSize="12" | |
| VerticalAlignment="Center" TextWrapping="WrapWithOverflow"> | |
| Context menu | |
| item with tooltip. The offset properties are set which causes the menu | |
| to appear outside the button control. | |
| </TextBlock> | |
| <DockPanel Margin="10, 10, 0, 0" Grid.Column="0" Grid.Row="4"> | |
| <Button Height="30"> | |
| Choose a Pet | |
| <Button.ContextMenu> | |
| <!--<SnippetContextMenuPlacement>--> | |
| <ContextMenu Placement="Bottom" PlacementRectangle="30,50,0,0"> | |
| <!--</SnippetContextMenuPlacement>--> | |
| <MenuItem Header="Animals"> | |
| <MenuItem> | |
| <MenuItem.Header> | |
| <Image Source="data/cat.png"/> | |
| </MenuItem.Header> | |
| </MenuItem> | |
| <MenuItem> | |
| <MenuItem.Header> | |
| <Image Source="data/dog.png"/> | |
| </MenuItem.Header> | |
| </MenuItem> | |
| <MenuItem> | |
| <MenuItem.Header> | |
| <Image Source="data/fish.png"/> | |
| </MenuItem.Header> | |
| </MenuItem> | |
| </MenuItem> | |
| </ContextMenu> | |
| </Button.ContextMenu> | |
| </Button> | |
| </DockPanel> | |
| <TextBlock Margin="10, 10, 5, 5" Grid.Column="1" Grid.Row="4" FontSize="12" | |
| VerticalAlignment="Center" TextWrapping="WrapWithOverflow"> | |
| Image used as a context menu item. | |
| </TextBlock> | |
| <DockPanel Margin="10, 10, 0, 0" Grid.Column="0" Grid.Row="5"> | |
| <!--<Snippet3>--> | |
| <Button Height="30" Content="Disabled Button" IsEnabled="False" | |
| ContextMenuService.ShowOnDisabled="True"> | |
| <Button.ContextMenu> | |
| <ContextMenu> | |
| <MenuItem Header="Item 1"/> | |
| <MenuItem Header="Item 2"/> | |
| <MenuItem Header="Item 3"/> | |
| </ContextMenu> | |
| </Button.ContextMenu> | |
| </Button> | |
| <!--</Snippet3>--> | |
| </DockPanel> | |
| <TextBlock Margin="10, 10, 5, 5" Grid.Column="1" Grid.Row="5" FontSize="12" | |
| VerticalAlignment="Center" TextWrapping="WrapWithOverflow"> | |
| Using context menu | |
| service to display a context menu on a disabled button. | |
| </TextBlock> | |
| <Button Height="30" Margin="10, 10, 0, 0" Grid.Column="0" Grid.Row="6" Click="OnClick"> | |
| Left click me to create a context menu with C# code. | |
| </Button> | |
| <TextBlock Margin="10, 10, 5, 5" Grid.Column="1" Grid.Row="6" FontSize="12" | |
| VerticalAlignment="Center" TextWrapping="WrapWithOverflow"> | |
| Creating a context menu with C#. | |
| </TextBlock> | |
| <!--<SnippetEvents>--> | |
| <TextBox Name="textBox1" | |
| TextWrapping="Wrap" | |
| Margin="10, 10, 5, 5" Grid.Row="7"> | |
| The quick brown fox jumps over the lazy dog. | |
| <TextBox.ContextMenu> | |
| <ContextMenu> | |
| <MenuItem Header="_Bold" | |
| IsCheckable="True" | |
| Checked="Bold_Checked" | |
| Unchecked="Bold_Unchecked" /> | |
| <MenuItem Header="_Italic" | |
| IsCheckable="True" | |
| Checked="Italic_Checked" | |
| Unchecked="Italic_Unchecked" /> | |
| <Separator /> | |
| <MenuItem Header="I_ncrease Font Size" | |
| Click="IncreaseFont_Click" /> | |
| <MenuItem Header="_Decrease Font Size" | |
| Click="DecreaseFont_Click" /> | |
| </ContextMenu> | |
| </TextBox.ContextMenu> | |
| </TextBox> | |
| <!--</SnippetEvents>--> | |
| </Grid> | |
| <Canvas Name="cv2" Width="550" Height="50" Canvas.Top="305" Canvas.Left="10"></Canvas> | |
| </Canvas> |