c# - WPF: Binding with two different lists -
c# - WPF: Binding with two different lists -
i have few problems databinding in wpf.
i have listbox has binding bindinglist.
<listbox x:name="samplelistbox" itemssource="{binding list1}" itemcontainerstyle="{staticresource listboxstyle}" borderthickness="0" selectedindex="0" margin="0"> <listbox.itemtemplate> <datatemplate > <border x:name="border" width="185"> <textblock text="{binding name}"/> </border> </datatemplate> </listbox.itemtemplate> </listbox>
till here, works fine. have datagrid should linked bindinglist , display strings of it. example, if first item of listbox selected, grid should show info of first item of sec list. know, how work if both, listbox , grid info same list, have no idea, do, if not possible , there 2 different lists.
you bind selectedindex listbox command property of type int (property1) in viewmodel.
also two-way bind selecteditem in datagrid property (property2) of sec list type.
in setter property1, alter property2 item @ index of property1 - i.e. list2[property1]. should alter selected item in datagrid.
c# wpf list listbox
Comments
Post a Comment