c# - Child dataGrid dataContext is being set to parent dataGrid causing binding Error -
i have parent , kid datagrid as:
<datagrid name="dispositionncrsgrid" itemcontainerstyle="{staticresource maindatagriditemstyle}" itemssource="{binding path=parentsource}" > <datagrid.rowdetailstemplate> <datatemplate> <datagrid selectionmode="single" itemssource="{binding myitemsource}" style="{dynamicresource maindatagridstyle}" horizontalalignment="center" >
now problem kid grid looking myitemsource
within parentsource
instead of current viewmodel.
how reset kid datagrid access info current viewmodel
if want myitemsource
detail datagrid
same view model main datagrid
takes parentsource
can utilize relativesource
binding , go visual tree find parent datagrid
, utilize datacontext
itemssource="{binding relativesource={relativesource mode=findancestor, ancestortype={x:type datagrid}}, path=datacontext.myitemsource}"
c# wpf datagrid
No comments:
Post a Comment