Display a Context Menu with Opacity : Menu « Windows Presentation Foundation « VB.Net

Display a Context Menu with Opacity

Display a Context Menu with Opacity
<Window x:Class="WpfApplication1.Window1"
    Title="WPF" Height="100" Width="300">
        <TextBox FontSize="16"  Height="23" Name="txtTextBox" >
                <ContextMenu HasDropShadow="True" Opacity=".8">
                    <MenuItem Command="Cut" Header="Cu_t" />
                    <MenuItem Command="Copy" Header="_Copy" />
                    <MenuItem Command="Paste" Header="_Paste" />
                    <MenuItem Click="SelectAll_Click" Header="_Select All" />
                    <MenuItem Click="Clear_Click" Header="_Clear" />
                    <MenuItem Header="Format">
                        <MenuItem Click="TextStyle_Click" Header="_Normal" Name="miNormal"></MenuItem>
                        <MenuItem Click="TextStyle_Click" FontWeight="Bold" Header="_Bold" Name="miBold"></MenuItem>
                        <MenuItem Click="TextStyle_Click" FontStyle="Italic" Header="_Italic" Name="miItalic"></MenuItem>
            A TextBox control with ContextMenu.
Imports System.Windows

Namespace WpfApplication1
  Public Partial Class Window1
    Inherits Window
    Public Sub New()
    End Sub
    Private Sub Clear_Click(sender As Object, e As RoutedEventArgs)
    End Sub
    Private Sub SelectAll_Click(sender As Object, e As RoutedEventArgs)
    End Sub
    Private Sub TextStyle_Click(sender As Object, e As RoutedEventArgs)
      If sender Is miNormal Then
        txtTextBox.FontWeight = FontWeights.Normal
        txtTextBox.FontStyle = FontStyles.Normal
      ElseIf sender Is miBold Then
        txtTextBox.FontWeight = FontWeights.Bold
      ElseIf sender Is miItalic Then
        txtTextBox.FontStyle = FontStyles.Italic
      End If
    End Sub
  End Class
End Namespace


Related examples in the same category

1.Mixed MenusMixed Menus
2.Sidebar MenuSidebar Menu
3.Put a Menu and toolbar on the top of a DockPanelPut a Menu and toolbar on the top of a DockPanel
4.Nesting content inside MenuItem.HeaderNesting content inside MenuItem.Header
5.Multiple command targetsMultiple command targets
6.Commands with a menu and text boxCommands with a menu and text box
7.Set Access key for Menu with underscoreSet Access key for Menu with underscore
8.Menu and MenuItemMenu and MenuItem
9.MenuItem Commands And EventsMenuItem Commands And Events
10.MenuBar and ToolBarMenuBar and ToolBar
11.Add Menu to NavigationWindow ContentAdd Menu to NavigationWindow Content
12.Menu item action handlerMenu item action handler