c# - WPF DataGrid RowDetails Visibility binding to a property (with XAML only) -
i have datagrid displaying bunch of objects. objects have property isdetailsexpanded
, want bind datarows detailsvisibility
property property.
my first approach works requires code-behind (which rid of)
i handle loadingrow
event
void loadingrowhandler(object sender, datagridroweventargs e) { binding b = new binding() { source = e.row.datacontext, path = new propertypath("isexpanded"), converter = (ivalueconverter)resources["booltovisi"], mode = bindingmode.twoway }; e.row.setbinding(datagridrow.detailsvisibilityproperty, b); }
i think there has way achieve similar in xaml unfortunately have not slightest clue. ideas? suggestions?
you can use style datagridrow
type, so:
<datagrid name="datagrid1" margin="12,12,0,0"> <datagrid.rowstyle> <style targettype="datagridrow"> <setter property="detailsvisibility" value="{binding isexpanded, converter={staticresource booltovisi}}" /> </style> </datagrid.rowstyle> </datagrid>
Comments
Post a Comment