c# - How to change selected row color in DataGrid Mahapp -
i'm trying change color of selected row can't result. i've tryed this:
<datagrid style="{staticresource azuredatagrid}">
but change can see first column colored azure. when select row, becomes white , can't see values on row selected. i'm new framework
theme wpf , documentation isn't accurate. can me?
changing selected row brush possible latest alpha version of mahapps.metro (1.1.3.x or later 1.2.0)
here example main demo
<datagrid x:name="metrodatagrid" grid.column="1" grid.row="1" renderoptions.cleartypehint="enabled" textoptions.textformattingmode="display" headersvisibility="all" margin="5" selectionunit="fullrow" itemssource="{binding path=albums}" autogeneratecolumns="false"> <datagrid.columns> <datagridcheckboxcolumn elementstyle="{dynamicresource metrodatagridcheckbox}" editingelementstyle="{dynamicresource metrodatagridcheckbox}" header="isselected" binding="{binding relativesource={relativesource ancestortype=datagridrow}, path=isselected, mode=oneway}" /> <datagridtextcolumn header="title" binding="{binding title}" /> <datagridtextcolumn header="artist" binding="{binding artist.name}" /> <datagridtextcolumn header="genre" binding="{binding genre.name}" /> <controls:datagridnumericupdowncolumn header="price" binding="{binding price}" stringformat="c" minimum="0" /> </datagrid.columns> <datagrid.style> <style basedon="{staticresource metrodatagrid}" targettype="{x:type datagrid}"> <setter property="alternatingrowbackground" value="{dynamicresource graybrush10}" /> </style> </datagrid.style> <datagrid.rowstyle> <style basedon="{staticresource metrodatagridrow}" targettype="{x:type datagridrow}"> <style.triggers> <datatrigger binding="{binding price, mode=oneway, converter={staticresource albumpriceistoomuchconverter}}" value="true"> <setter property="background" value="#ff8b8b" /> <setter property="foreground" value="red" /> </datatrigger> <!-- ismouseover --> <multidatatrigger> <multidatatrigger.conditions> <condition binding="{binding price, mode=oneway, converter={staticresource albumpriceistoomuchconverter}}" value="true" /> <condition binding="{binding path=ismouseover, relativesource={relativesource self}}" value="true" /> </multidatatrigger.conditions> <setter property="background" value="#ffbdbd" /> </multidatatrigger> </style.triggers> </style> </datagrid.rowstyle> <datagrid.rowvalidationrules> <valueconverter:albumpriceisreallytoomuchvalidation validatesontargetupdated="true" validationstep="committedvalue" /> <valueconverter:albumpriceisreallytoomuchvalidation validatesontargetupdated="true" validationstep="updatedvalue" /> </datagrid.rowvalidationrules> </datagrid>
Comments
Post a Comment