|
<Window.DataContext>
<local:ViewModel />
</Window.DataContext>
<Window.Resources>
<local:ColorConverter x:Key="converter"/>
<Style TargetType="syncfusion:VirtualizingCellsControl">
<Setter Property="Background" Value="{Binding Converter={StaticResource converter}}" />
</Style>
</Window.Resources>
<Grid>
<syncfusion:SfDataGrid x:Name="dataGrid" ItemsSource="{Binding Orders}" >
<syncfusion:SfDataGrid.Columns>
<syncfusion:GridTextColumn IsHidden="True" MappingName="Country"/>
</syncfusion:SfDataGrid.Columns>
</syncfusion:SfDataGrid>
</Grid>
public class ColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var input = (value as OrderInfo).OrderID;
//custom condition is checked based on data.
if (input < 1003)
return new SolidColorBrush(Colors.Bisque);
else if (input < 1007)
return new SolidColorBrush(Colors.LightBlue);
else if (input >= 1007)
return new SolidColorBrush(Colors.Yellow);
else
return DependencyProperty.UnsetValue;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
} |