WPF DataGrid: Change the MouseOverBrush Color

Highlighting data on mouse-over keeps your grid readable. ComponentOne Studio WPF DataGrid Mouse-Over If you don't like built-in mouse hover style of DataGrid for WPF, you can quickly change it to match your theme, or disable it completely. It only takes a line of code, or a single property set in your XAML markup. In XAML view, locate your tag. It should look something like the following: Add MouseOverBrush="Yellow" to the markup: And you're done! When you run your application, moused over cells will be highlighted in yellow. If you prefer working in code, try adding the following to your project: Visual Basic

Me.c1datagrid1.MouseOverBrush = New System.Windows.Media.SolidColorBrush(Colors.Yellow)

C#

this.c1datagrid1.MouseOverBrush = new System.Windows.Media.SolidColorBrush(Colors.Yellow);

Again, that's it! When you run your application and mouse over a row or column, it'll look like the following image: ComponentOne Studio WPF DataGrid Mouse-Over Style Yellow For more easy ways to customize your Grid, including information on templates, check out the documentation.

GrapeCity

GrapeCity Developer Tools
comments powered by Disqus