Use of WPF ContextMenu, wpfcontextmenu

Source: Internet
Author: User

Use of WPF ContextMenu, wpfcontextmenu

<Grid. contextMenu> <MenuItem Header = "add" Click = "MenuItem_Click"> </MenuItem> <MenuItem Header = "delete"> </MenuItem> <MenuItem Header = "Modify "> </MenuItem> </ContextMenu> </Grid. contextMenu> Add an image to the ContextMenu <MenuItem Header = "add" Click = "MenuItem_Click"> <MenuItem. icon> <Image Source = "image/titleIcon. ico "> </Image> </MenuItem. icon> </MenuItem> Add a split entry to the ContextMenu <Separator> </Separator>

 


Multiple calls to ContextMenu in WPF

In <Window. Resources>

</Window. Resources>
Medium,
You can use StaticResouce to call it later.

How to close the ContextMenu In the shortcut menu of the WPF tray icon

NotifyIcon has a ContextMenuStrip attribute. You can set this attribute directly. Do not set this attribute in the click event. This is intercepted in a previously written project. Stick it to it for you to see:
System. Windows. Forms. ContextMenuStrip contextMenu = new System. Windows. Forms. ContextMenuStrip ();
System. Windows. Forms. ToolStripMenuItem item1 = new System. Windows. Forms. ToolStripMenuItem ();
Item1.Click + = new EventHandler (item1_Click );
Item1.Text = "display main panel ";
System. Windows. Forms. ToolStripMenuItem item2 = new System. Windows. Forms. ToolStripMenuItem ();
Item2.Text = "quit ";
Item2.Click + = new EventHandler (item2_Click );
ContextMenu. Items. Add (item1 );
ContextMenu. Items. Add (item2 );
This. policyicon. ContextMenuStrip = contextMenu;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.