Tuesday 15 February 2011

c# - CommandBinding in ContextMenu -


I have a tree view and I have created a basic tree eTem type. Each tree has headers in ITEM, a collection of toys for children and a collection of potential reference menus. There are those items in the Tryitum class:

  public representative zero dexactec (tree item); Public Dextech Execute target {receive; Set; } Public Object Tag {get; Set; } Public String Header {get; Set; } Public listing & lt; TreeItem & gt; Children {receive; Set; } Public listing & lt; TreeItem & gt; {Get Context Menu; Set; }   

Use the context menu again to display a hierarchical data template to display TreeItem objects (I use the TreeItem class for the items in the preview and in the context menu). The context menu looks like this:

  & lt; ContextMenu DataContext = "{Binding placement targets. Detacontekst, relative Sors = {relative Srs Self}}" visibility = "{Baining Socontekst menu}" items Source = "{Binding ContextMenu}" & gt; & Lt; ContextMenu.ItemTemplate & gt; & Lt; Hierarchical data items source = "{binding child}" & gt; & Lt; Text block text = "{binding header}" /> & Lt; HierarchicalDataTemplate.ItemContainerStyle & gt; & Lt; Style TargetType = "MenuItem" & gt; & Lt; Setter property = "command" value = "{binding execution}" /> & Lt; / Style & gt; & Lt; /HierarchicalDataTemplate.ItemContainerStyle> & Lt; / HierarchicalDataTemplate & gt; & Lt; /ContextMenu.ItemTemplate> & Lt; / ContextMenu & gt;   

is provided as a context menu because I want it to be. I have created a context menu which I attach to some of my objects in the tree view. This is its content

  public list & lt; TreeItem & gt; Contekstmenu ({list & lt; Tryaitm & gt; list = new List & lt; tree item & gt; (); Tree Itam TI = new Tryitm ( "some action") {ExecuteTarget = targetMethod}; list.Add (ti) ; t = new tree items ( "test"); Ti.Children.Add (new TreeItem ( "foo") {ExecuteTarget = targetMethod}); Ti.Children.Add (new TreeItem ( "bar") {ExecuteTarget = targetMethod} ); Ti.Children.Add (new TreeItem ( "foo") {ExecuteTarget = targetMethod}); Tryaitm TI 2 = new Tryitm ( "inner") {ExecuteTarget = targetMethod}; ti.Children.Add (ti2); Ti2. Children.Add (New TreeItem ("foo") {ExecuteTarget = targetMethod}); list.Add (ti); return list;}}   

The context menu looks like this.

context menu provided

It seems that it should be. I want to add something to XML, but I do not know where to go, when I click on "some action". is.

  & lt; ContextMenu DataContext = "{Binding placement targets. Detacontekst, relative source = {relative Srs Self}}" visibility "" {Binding Dikhaaacontekst menu} "Aitmssors =" {Binding context menu} "& gt; & LT; ContextMenu.ItemTemplate & gt ; & Lt; Pdanukrmitdeta item before source = "{binding Children}" & gt; & Lt; Tekstblok text = "{binding header}" / & gt; & LT; HierarchicalDataTemplate.ItemContainerStyle & gt; & Lt; TargetType style = " MenuItem "& gt; Setter Property =" Command "value =" {Binding Mr. execution} "/ & gt; & Lt; / style & gt; & LT; /HierarchicalDataTemplate.ItemContainerStyle> & Lt; / HierarchicalDataTemplate & gt; & LT; /ContextMenu.ItemTemplate> & Lt ;! - This is what you Sasa - & gt; & LT; ContextMenu.ItemContainerStyle & gt; & Lt; style TargetType = "MenuItem" & gt; & Lt; setter property = "command" value = "{binding performance}" / & gt; & Lt; / style & gt; & lt; /ContextMenu.ItemContainerStyle>); / ContextMenu & gt;    

No comments:

Post a Comment