wpf - DataGrid.RowStyle only works on initial binding -
i have datatrigger applying style visibility property of datagrid row. datatrigger working fine on initial binding of datagrid (ie - sets row visibility collapsed if filteredout true).
i have combobox sets filteredout property true or false each item in observablecollection allpartmalfunctions depending upon user has selected in combobox.
here problem: after selecting item in combobox , setting filteredout property each item, the datagrid rows not refresh visible or collapsed , on ui looks same did before selecting in combobox. missing?
here xaml:
<datagrid itemssource="{binding allpartmalfunctions}" autogeneratecolumns="false" width="auto"> <datagrid.rowstyle> <style targettype="datagridrow"> <style.triggers> <datatrigger binding="{binding filteredout, mode=twoway}" value="true"> <setter property="visibility" value="collapsed" /> </datatrigger> <datatrigger binding="{binding filteredout, mode=twoway}" value="false"> <setter property="visibility" value="visible" /> </datatrigger> </style.triggers> </style> </datagrid.rowstyle> <datagrid.columns> <!--removed brevity--> </datagrid.columns> </datagrid>
here viewmodel datagrid binding:
public class malfunctions : viewmodelbase { public observablecollection<model.partmalfunction> allpartmalfunctions { get; private set; } }
here partmalfunction model:
public class partmalfunction { private bool _filteredout = false; public bool filteredout { { return _filteredout; } set { _filteredout = value; } } }
class "partmalfucntion" needs implement system.componentmodel.inotifypropertychanged , fire off propertychanged event when filteredout's value changed.
public class partmalfunction : system.componentmodel.inotifypropertychanged { #region inotifypropertychanged members public event system.componentmodel.propertychangedeventhandler propertychanged; #endregion private bool _filteredout = false; public bool filteredout { { return _filteredout; } set { _filteredout = value; if (propertychanged != null) propertychanged(this, new system.componentmodel.propertychangedeventargs("filteredout")); } } }
Comments
Post a Comment