c# - Change DataGridTemplateColumn content style -


i want change datagridtemplatecolumn content style, here datagridtemplatecolumn code:

<datagridtemplatecolumn maxwidth="50" minwidth="30" cellstyle="{staticresource cellstyle}"> <datagridtemplatecolumn.celltemplate>     <datatemplate>         <label style="{staticresource fontawesome}" padding="0" verticalalignment="center" horizontalalignment="center" cursor="hand" mouseleftbuttondown="lbledit_mouseleftbuttondown">                      </label>     </datatemplate> </datagridtemplatecolumn.celltemplate> </datagridtemplatecolumn> 

here cellstype code:

<style x:key="cellstyle" targettype="datagridcell">     <setter property="borderthickness" value="0 0 1 0"/>     <setter property="borderbrush" value="#f6f6f6"/>     <setter property="foreground" value="#000"/>     <setter property="fontsize" value="14" />     <style.triggers>         <trigger property="datagridcell.isselected" value="true">             <setter property="background" value="#ff5750" />             <setter property="foreground" value="#ffffff" />         </trigger>     </style.triggers> </style> 

enter image description here

but label in datatemplate not effect when row select althought other cell effect.

any way make it?

thankyou!

the trigger sets foreground color of datagridcell not of label. can reference foreground color in label adding foreground attribute it:

<label      style="{staticresource fontawesome}"      foreground="{binding relativesource={relativesource findancestor, ancestortype=control}, path=foreground}"     ... /> 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -