c# - How to bind in WPF a whole object to an user control? -


People often do something like:

  & lt; List box itemsource = "{binding element name = this control, path = list index}" & gt; & Lt; ListBox.ItemTemplate & gt; & Lt; DataTemplate & gt; & Lt; StackPanel & gt; & Lt; Label content = "{binding path = indexing name}" /> & Lt; Label content = "{binding path = index value}" /> & Lt; / StackPanel & gt; & Lt; / DataTemplate & gt; & Lt; /ListBox.ItemTemplate> & Lt; / ListBox & gt;  

But instead of labels, I would like to use a control like this:

  & lt; List box itemsource = "{binding element name = this control, path = ListIndexes}" & gt; & Lt; ListBox.ItemTemplate & gt; & Lt; DataTemplate & gt; & Lt; Local: index item = "** {binding} **" /> & Lt; / DataTemplate & gt; & Lt; /ListBox.ItemTemplate> & Lt; / ListBox & gt;  

My suspicion is to keep this binding to include the entire item from the collection.

The syntax for this is:

  & lt; Local: index item = "{binding}" />  

This will bind the data binding functions to the item properties for each list box item in its index control by placing the whole datacentext in the item property


Comments