c# - How to set DataGrid line color in DataTrigger? -
how can set different grid line color rows in datagrid through datatrigger?
i tried this:
<datagrid ...> <datagrid.rowstyle> <style targettype="datagridrow"> <style.triggers> <datatrigger binding="{binding in_stock, converter={conv:lessthan 4}}" value="true"> <setter property="borderbrush" value="red" /> </datatrigger> </style.triggers> </style> </datagrid.rowstyle> </datagrid>
but grid lines same, default color.
just try method
<window.resources> <style x:key="highlightcell" targettype="datagridcell" basedon="{staticresource {x:type datagridcell}}"> <style.triggers> <datatrigger binding="{binding in_stock}" value="true"> <setter property="borderbrush" value="red" /> </datatrigger> </style.triggers> </style> </window.resources> <grid> <datagrid grid.row="3" itemssource="{binding datagridpersonlist}" selecteditem="{binding selecteddatagridperson}" cellstyle="{staticresource highlightcell}" autogeneratecolumns="false" > <datagrid.columns> <datagridtextcolumn header="status" binding="{binding status}" width="*" > </datagridtextcolumn> <datagridtextcolumn header="name" binding="{binding name}" width="*" /> </datagrid.columns> </datagrid> </grid>
Comments
Post a Comment