First off, the title may not be a good one.
I’m using WPF 4 DataGrid a lot. One feature I’d like to have is to highlight the mouse over row. My first attempt is to change the background color using a Trigger on DataGridRow. However, there is a conflict with the read-only datagrid cells, see my other post here. Now, the next best thing I can do is to add a border to the mouse over row. This can easily be done with this style:
<Style TargetType="DataGridRow">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>
The problem is that some of the DataGrid have star sized columns, and it doesn’t normally show horizontal scrollbar. However, with this style Trigger, because it’s adding one unit border, the scrollbar becomes visible when mouse is over the grid. I thought it could be resolved if I could make the star column a little bit smaller. Is it possible? Or do you have any other idea?
EDIT: Even if I change the value for border thickness to “1 1 0 1” (so to make it borderless at right), the scrollbar still shows up.
You may try reducing the DataGridRow’s margins.
Two caveats for the value I gave: The right-side border line does not appear, no matter what you set the margin to, although that may be true even without the margin setter. And when the trigger activates for your “last” or “bottom” row, the column headers shift (in this case, they all shift to the right a bit).