/wpf-context-menu-create

Create a context menu and display it for a text box.

Primary LanguageVisual Basic .NETOtherNOASSERTION

WPF Menu - Display a Context Menu for a Text Box

This example demonstrates how to create a popup menu with Copy, Paste, Undo, and Redo commands (bar items). The menu is displayed when the user right-clicks in the text box.

WPF Context Menu - Display a Context Menu for a Text Box

The BarManager.DXContextMenu attached property is used to associate the menu with a TextBox control:

<TextBox
  ...
  <dxb:BarManager.DXContextMenu>
      <dxb:PopupMenu>
          <dxb:PopupMenu.Items>
              <dxb:BarButtonItem
                  Content="Copy"
                  Glyph="pack://application:,,,/Images/copy16x16.png"
                  ItemClick="itemCopy_ItemClick" />
              <dxb:BarButtonItem
                  Content="Paste"
                  Glyph="pack://application:,,,/Images/paste16x16.png"
                  ItemClick="itemPaste_ItemClick" />
              <dxb:BarButtonItem
                  Content="Undo"
                  Glyph="pack://application:,,,/Images/undo16x16.png"
                  ItemClick="itemUndo_ItemClick" />
              <dxb:BarButtonItem
                  Content="Redo"
                  Glyph="pack://application:,,,/Images/redo16x16.png"
                  ItemClick="itemRedo_ItemClick" />
          </dxb:PopupMenu.Items>
      </dxb:PopupMenu>
  </dxb:BarManager.DXContextMenu>
</TextBox>

Files to Review

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)