c# - DataBinding between two custom listbox -


what want

i have 2 custom listbox inside usercontrol.

my custom listbox1 has private list<element> sublist sub-list of elements. custom control implements propertychanged of inotifypropertychanged etc etc.

my listbox2 has display sub-list.

both of them using datatemplate not think problem here not take care of part here. if wrong, let me know , update example.

what want

what tried

<usercontrol>         <local:listbox1 x:name="listbox1"                           datacontext="{binding myfulllist}"/>         <local:listbox2 x:name="listbox2"                          datacontext="{binding elementname=listbox1}"                         content="{binding path=sublist}"/> </usercontrol> 

it's giving me inside listbox2:

(collection)

i tried using 1 element instead of list of elements , working. tried this:

<usercontrol>             <local:listbox1 x:name="listbox1"                               datacontext="{binding myfulllist}"/>             <local:listbox2 x:name="listbox2"                              datacontext="{binding elementname=listbox1, path=sublist}"/> </usercontrol> 

but giving me nothing... tried using observablecollection instead of list still nothing.

my questions

what should binding fill listbox2 sublist of listbox1? doing wrong ?

without seeing model class guess, if have model tha contains sublist can bind listbox1.selecteditem , use sublist property

 <local:listbox2 x:name="listbox2" datacontext="{binding elementname=listbox1, path=selecteditem.sublist}"/> 

Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -