WPF Context menu on left click

后端 未结 8 512
情深已故
情深已故 2020-12-01 10:39

I have a WPF application..In which I have an Image control in Xaml file.

On right click of this image I have a context menu.

I would like to have same to be

8条回答
  •  误落风尘
    2020-12-01 10:59

    Hey I came across the same problem looking for a solution which I didn't find here.

    I don't know anything about MVVM so it's probably not MVVM conform but it worked for me.

    Step 1: Give your context menu a name.

    
        
    
    

    Step 2: Double click the control object and insert this code. Order matters!

    Private Sub Button_Click_1(sender As Object, e As Windows.RoutedEventArgs)
            cmTabs.StaysOpen = True
            cmTabs.IsOpen = True
        End Sub
    

    Step 3: Enjoy

    This will react for left & right click. It's a button with a ImageBrush with a ControlTemplate.

提交回复
热议问题