I have been messing around with datagrid styling for a couple of days now, and I am having one issue left which I can not seem to solve.
I want to highligt the text of the row on which I hover with the mouse. Well this seems like an easy task, but at the same time I want custom selection color of the row background and foreground. This combination seems impossible for me to solve.
If I override the datagridrow style I can get everything but the selection style on the row. If I also override the datagridcell style, I can get everything but the mouseover foreground full row highlight. What I have below is complete styling I have come up with so far. I know it contains duplicate attributes for the same tasks, but I have been trying everything. Only the complete row mouseover highlight is missing - only the hovered cell is highlighted.
Can you help me solve this tiny detail?
The code below is attached as a zip file. Alternatively put the below code in a WPF Window (I know the coloring is awful, they are just for the example):
OK - my initial problem was, that I used a basestyle, which all other styles inherited from. This meant that styles such as Foreground was overriden multiple times through the style hierarchy. This messed thing up bad enough to make the above impossible.
The solution for me was to removed the BasedOn attribute of all datagrid styles except the DataGrid itself (datagridrowheader, datagridrow, datagridcell). Set the foreground color only on the DataGrid and you can override it in the row and cell styles with no problem.