WPF MVVM: how to create & show a context menu? -


For my WPF application I am using MVVM, and now when I right-click the user I want to show a generated reference menu. on some.
Right-clicking was easy to take some action, but how do I show a context menu that is generated by ViewModel?

I also do not have an idea of ​​where to start, to display a context menu, because I do not have direct access to the scene in MVVM.

Delay in answering; I just set my garbage data source so I can display some types of data. It only shows when I right click on the first column title and nobody else ... which I think is what you want, right? Tell me how you get acquainted ... will continue to think about any investigation.

  & lt; Grid & gt; & Lt; ListView margin = "8,833,12" item resource = "{binding source = {static processing content}, path = MyCollection}" & gt; & Lt; ListView.View & gt; & Lt; GridView & gt; & Lt; GridViewColumn Width = "100" DisplayMemberBinding = "{Binding}" & gt; & Lt; GridViewColumnHeader & gt; Product Name & lt; GridViewColumnHeader.ContextMenu & gt; & Lt; ContextMenu name = "MyMenu" & gt; & Lt; MenuItem Header = "Sort ..." /> & Lt; MenuItem Header = "Follow Link ..." /> & Lt; / ContextMenu & gt; & Lt; /GridViewColumnHeader.ContextMenu> & Lt; / GridViewColumnHeader & gt; & Lt; / GridViewColumn & gt; & Lt; GridViewColumn Width = "100" header = "Product Name" DisplayMemberBinding = "{Binding Path = Length}" /> & Lt; / GridView & gt; & Lt; /ListView.View> & Lt; / ListView & gt; & Lt; / Grid & gt;  

Comments