data binding - WPF DataGrid RowHeader databinding -
i have datagrid, bound datatable. want display text in rowheader, achieve this:
col0 col1 col2 col3 table | 1 | 3 | 5 | 6 | chair | 3 | 2 | 1 | 8 | is possible , if so, how can this?
i tried both answers, , neither worked me. had mix them together.
this works me:
<datagrid name="ui_datagrid> <datagrid.rowheadertemplate> <datatemplate> <textblock text="{binding relativesource={relativesource mode=findancestor, ancestortype={x:type datagridrow}}, path=item.header}"/> </datatemplate> </datagrid.rowheadertemplate> </datagrid> the trick find ancestor datagridrow, bind textblock.text attribute item's property care about, in case header (easier said in xaml english maybe).
then in .xaml.cs:
ui_datagrid.itemssource = datasource.rows; n.b. each row object has header property i'm binding too.
Comments
Post a Comment