Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Turn off or change color of datagrid Mouse Hover effect
3 replies. Latest Post by imohamed on December 23, 2008.
(0)
imohamed
Member
9 points
27 Posts
12-23-2008 12:30 PM |
Is there a way I can turn off or change the color of the mouse over hover effect in datagrid? Thanks
GuinnessKMF
222 points
58 Posts
12-23-2008 12:56 PM |
The DataGrid Styles and Templates (http://msdn.microsoft.com/en-us/library/cc278066(vs.95).aspx) contains the information you need to change control behavior that is not exposed by a public property.
By changing the style of the DataGridRows of your DataGrid you can recreate the template with a different "BackgroundRectangle" Fill, or you can change the MouseOver storyboard to not adjust the opacity of that rectangle.
12-23-2008 1:10 PM |
So if what I said wasn't clear enough. You want to create a staticResource that is a style that's an exact copy of the DataGridRow from the link. Then you want to change that style to meet your needs (setting opacity to 0 for the mouseover to property, or changing the color of the BackgroundRectangle), and then set the style of your DataGrid's RowStyle to {StaticResource KeyOfStyle}. <UserControl x:Class="YourControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
<
12-23-2008 4:06 PM |
Kellen
You are great!!! I got it working just by copy and paste your code and made small changes!!! You are awsome.. thanks..
I have one other problem. The fist cell (row=0, collumn=0) is shown as selected when the grid is loaded. Where do I turn off that effect? I set all the opacity for Selected state to 0.
Thanks