求助如何获取WPF根据右键菜单的源控件

真钱捕鱼,依赖代码:privatevoidnew_Click(objectsender,RoutedEventArgse卡塔尔国{NodeLoopNode=newNode(State of Qatar{NodeName="New",IsExpanded=true};//vartreeViewItem=((e.SourceasMenuItem卡塔尔(قطر‎.ParentasContextMenu卡塔尔国.PlacementTargetasTreeViewItem;vartreeViewItem=ContextMenuService.GetPlacementTarget(HelLogicalTreeper.GetParent(senderasMenuItem卡塔尔asTreeViewItem;BindingExpressionbindingdata=treeViewItem.GetBindingExpression(TreeView.ItemsSourcePropertyState of Qatar;varnode=bindingdata.DataItemasNode;node.Children.Add(LoopNodeState of Qatar;this.Tree.ItemsSource=children;}调节和测量检验监察和控制发掘treeViewItem总是为null,求大佬扶助

返回列表