c# - ItemsControl item selection binding -
i have view defined below,
<itemscontrol itemssource={binding c1.coll1}> .... <itemscontrol.itemtemplate> <datatemplate datatype="{x:type vm:c2}"> <expander header="{binding name}"> <listbox itemssource={binding coll2}/> </expander> </itemscontrol.itemtemplate> </itemscontrol>
the associated view model this,
class c1 { public coll1<c2>; } class c2 { public name, public coll2 }
i can bind selection event of listbox c2. when event fires want fire c1. alternatives? tried binding selection event c1 did not work. there way bind or there alternatives that?
any appreciated.
note: please ignore syntax here, trying demonstrate view point minimum code. if interested in full code let me know can share it.
the itemssource of itemscontrol already in c1.
so need create two-way binding of selecteditem of itemssource property in c1. need change itemscontrol descendant of selector, e.g. listview. still have control on itemssource , appearance / templates.
<listview itemssource={binding collectionofc2items} selecteditem="{binding selectedc2item, mode=twoway, updatesourcetrigger=propertychanged}">
by setting updatesourcetrigger 'propertychanged' force property in c1 (the binding source) update selection changes in itemscontrol.
Comments
Post a Comment