views:

27

answers:

0

I have a TreeView which uses HierarchicalDataTemplate to generate its items and i want to have a context menu on items(markup below). The problem is that the menu is showing but when i click on any item nothing happens. I use MVVM so menu is bound to Commands. But i have another menu on the treeview itself and it works perfectly. How can i fix this and make items respond to menu item commands?

<sdk:HierarchicalDataTemplate ItemsSource="{Binding Queries}">
    <StackPanel  Orientation="Horizontal">
      <Image Source="{Binding Converter={StaticResource IconConverter}}" />                        
      <TextBlock Text="{Binding Name}"/>
      <my:ContextMenuService.ContextMenu>
        <my:ContextMenu>
          <my:MenuItem Header="Переименовать" Command="{Binding RefreshCommand}"></my:MenuItem>
          <my:MenuItem Header="Удалить" Command="{Binding RemoveCommand}" CommandParameter="{Binding}"></my:MenuItem>
        </my:ContextMenu>
      </my:ContextMenuService.ContextMenu>  
    </StackPanel>             
  </sdk:HierarchicalDataTemplate>