Context Menu触发器未在TreeViewItem上触发

在我的WPF应用程序中,我向TreeViewItems添加了一个TreeView控件绑定类数据。 我在treeviewitems中添加了一个上下文菜单。 contextMenu的处理程序没有触发。 这是TreeView的XAML代码。

                                         

这些是绑定到TreeView的两个类。

  ///  /// Class to hold the Pads info for a tree ///  public class Pad { ///  /// Default Constructor ///  public Pad() { this.Members = new ObservableCollection(); } ///  /// Name of the pad ///  public string Name { get; set; } ///  /// Members of the pad ///  public ObservableCollection Members { get; set; } } ///  /// Class to hold the well and slot IDs snapped to a pad ///  public class PadInfo { ///  /// Slot ID ///  public string SlotID { get; set; } ///  /// Well ID ///  public string WellID { get; set; } } 

}

该成员绑定到TreeView

 public List pads { get; set; } 

当我右键单击菜单项时,RenameCommand事件不会触发。 当我更改to处理程序时,但是TreeView没有填充绑定数据。

请帮忙。 谢谢

基本上我在这里缺少重要的代码,关于你的类在哪里有List,你绑定的命令在哪里? 此外,您正在使用CommandBinding。 这不像普通的事件处理程序。 这是WPF中的两件事。 我认为您在DataContext类中缺少命令的Property。