WPF context menu whose items are defined as data templates
问题 I have a list view that displays a collection of items, each item has as its underlying data a view model (MVVM). What I would like to do is display different menu items within the context menu when the user right clicks one of these list view items. The menu items displayed is dependent on the type of the item selected (i.e. the type of the underlying view model). I would expect the below to work, but it does not (no items are displayed in the context menu). <ListView.ContextMenu>