public class RowStyles : VirtualizingCellsControl
{
public StyleViruatl() :base()
{
}
protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e)
{
if (!String.IsNullOrEmpty((this.DataContext as MyClass).Column1.ToString()))
{
this.RowHoverBackgroundBrush = new SolidColorBrush(Colors.Red);
}
else
{
this.RowHoverBackgroundBrush = new SolidColorBrush(Colors.White);
}
base.OnMouseEnter(e);
}
protected override void OnMouseLeave(System.Windows.Input.MouseEventArgs e)
{
this.RowHoverBackgroundBrush = new SolidColorBrush(Colors.White);
base.OnMouseLeave(e);
}
}
public class CustomRowGenerator : RowGenerator
{
public CustomRowGenerator(SfDataGrid dataGrid)
: base(dataGrid)
{
}
protected override VirtualizingCellsControl GetVirtualizingCellsControl<T>()
{
//Set the customized VirtualizingCellsControl
if (typeof(T) == typeof(VirtualizingCellsControl))
return new RowStyles();
return base.GetVirtualizingCellsControl<T>();
}
} |