c# - Sub-menu for each binding item -


From the Omar van Coloton I filled out a menu with the left menu item from my executed collection, for a single collection item A single menu item is okay, but I really want more. I also want to be able to get a menu item containing two or three sub items for a collection item. Here's some weird sketch:

  what i want + first item + first item + second item + second item + delete + update   

here The "first item" contains the property = false , but in "second item" it is true my current code:

  public Class collection item {public string name {get} Set; } Public hair is present {get; Set; }} Public Partial Class Main Window: Window {Observing Collections & lt; CollectionItem & gt; item; Public Manvindo () {items = New Observation Collection & lt; Archive item & gt; (); item. Add (new collection item () {name = "first item", exists = wrong}); Items.Add (new store item () {name = "second item", exists = true}); AllItems.ItemsSource = Items; }} & Lt; MenuItem x: name = "All items" header = "what do i have" & gt; & Lt; MenuItem.ItemContainerStyle & gt; & Lt; Style TargetType = "{x: type menu item}" & gt; & Lt; Setter property = "header" value = "{binding path = name}" /> & Lt; / Style & gt; & Lt; /MenuItem.ItemContainerStyle> & Lt; / MenuItem & gt;   

How did I get simple menu items with sub items?

How do I mix simple menu items with sub items?

First, you need to structure your data, to represent the child with the properties of the collection, or to the sub MenuItem . After that, you need to use the data from the collection property to ItemSource parent menuItem property to MenuItem.ItemContainerStyle , just like That you are doing again 'should do something like this:

  public class collection command {public string name {get; Set; } Public hair is present {get; Set; } Public Observable Collections & lt; Archive item & gt; CollectionsOfficeSites {Receive; Set; }}   

...

  & lt; MenuItem x: name = "All items" header = "what do i have" & gt; & Lt; MenuItem.ItemContainerStyle & gt; & Lt; Style TargetType = "{x: type menu item}" & gt; & Lt; Setter property = "header" value = "{binding path = name}" /> & Lt; Setter Property = "ItemsSource" value = "{Compulsive CollectionOffsites}" /> & Lt; / Style & gt; & Lt; /MenuItem.ItemContainerStyle> & Lt; / MenuItem & gt;    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -