WPF 左键单击弹出菜单 ContextMenu

原文: WPF 左键单击弹出菜单 ContextMenu

WPF中的ContextMenu在XAML中可直接做出来,但是仅限于右键弹出菜单,如果需要添加左键弹出功能,只需要在事件中添加Click事件

XMAL代码如下

 

 

添加click事件的代码如下:

        private void s_Click(object sender, RoutedEventArgs e)
        {
            this.menu.PlacementTarget = this.s;
            this.menu.IsOpen = true;
        }

 

 

左键便可以弹出菜单

你可能感兴趣的:(WPF 左键单击弹出菜单 ContextMenu)