public class CustomVirtualizingCellsControl : VirtualizingCellsControl
{
void OnDataPropertyChanged(object sender, PropertyChangedEventArgs e)
{
var dataContext = this.DataContext as StockData;
if (dataContext != null)
{
if (dataContext.Change > 0 && dataContext.LastTrade >= 25)
this.Style = App.Current.Resources["rowStyle1"] as Style;
else
this.Style = App.Current.Resources["rowStyle2"] as Style;
}
}
}
public class CustomRowGenerator : RowGenerator
{
public CustomRowGenerator(SfDataGrid dataGrid)
: base(dataGrid)
{
}
protected override VirtualizingCellsControl GetVirtualizingCellsControl<T>()
{
if (typeof(T) == typeof(VirtualizingCellsControl))
return new CustomVirtualizingCellsControl();
return base.GetVirtualizingCellsControl<VirtualizingCellsControl>();
}
} |