c# - ListBox DataTemplate Binding With Two Lists -
I am doing a listbacking in one object that includes two array of string. Each list box item text box and combo box The data made from is set to the template. The first string array is linked to the list, and the second string is attached to the array combo box. Well, at least I'm trying to achieve this. The problem is that I can not find the binding syntax for setting the second array in the combo box. Here's what I have:
The first thing is that in my class there are two string arrays. I very straightforward. Please note that string array content is for simplicity
public class job assignments {public job assignments () {m_people.Add ("John"); M_people.Add ("Bill"); M_people.Add ("frank"); M_people.Add ("Steve"); M_jobs.Add ("Architect"); M_jobs.Add ("Teacher"); M_jobs.Add ("The Carpenter"); M_jobs.Add ("Plumber"); } Private listing & lt; String & gt; M_people = New list & lt; String & gt; (); Public listing & lt; String & gt; People {Get {return m_people; } Set {m_people = value; }} Private listing & lt; String & gt; M_jobs = new list & lt; String & gt; (); Public listing & lt; String & gt; In the code, I have set an example of this class as the datacontext of this listbox: {/ m_jobs;} set {{m_jobs = value;}}}; P> ListBox x: name = "listBox" grid line = "0" horizontal consultation alignment = "statch" datacentext = "{binding}" items source = "{binding world}" item template = "{Static resource job assentment data template}">
with a data template that is similar to Dates:
& gt; Datamapplet x: Key = "JobAssidamentTatemplate"> gt; & lt; Grid & gt; Grid.ColumnDefinitions & gt; & gt; ColumnDefinition / & gt; ; & Lt; ColumnDefinition / & gt; & lt; /Grid.ColumnDefinitions> & gt; TextBlock Grid.column = "0" text = "{binding}" />
Combo box grid.column = "2 "Selected index =" 0 "item source =" {binding jobs ????} "/> gt; & lt; / grid & gt; & lt; / dataTemplate & gt;
How do I usually get my experiments with people's list box, but Each list item's combo box is empty.
I can get it to work I use
ItemsSource = "{binding element name = listBox, path = DataContext.Jobs}" />
But I do not want to use ElementName because this is the source of the array trying to do some sort of hardcodes
which I would like to save a specific list box
itemsource = "{binding relative saras = {relative ss self}, path = parent.jobs}" />
It does not work because it is looking for jobs inside the grid.
A slight push in the right direction will be very helpful.
When you are in datataplate that represents only one person Try below which is not your job assignments image
itemsource = "{binding element name = list box, path = jobs}" />
But I do not recommend the above step. You need to reflect your own vulgar logic. I think 'jobs' can be a static example so that you can ax: static binding
itemsSource = "{binding source = {x: static job assignments}, path = jobs}"
Comments
Post a Comment