<Window.Resources>
<local:CustomRowStyleConverter x:Key="CustomRowStyleConverter" />
<local:AlternativeRowStyleConverter x:Key="AlternativeRowStyleConverter" />
<Style x:Key="rowStyle" TargetType="Syncfusion:VirtualizingCellsControl">
<Setter Property="Background" Value="{Binding Converter={StaticResource CustomRowStyleConverter}, UpdateSourceTrigger=PropertyChanged}" />
</Style>
<Style x:Key="alternativeRowStyle" TargetType="Syncfusion:VirtualizingCellsControl">
<Setter Property="Background" Value="{Binding Converter={StaticResource AlternativeRowStyleConverter},UpdateSourceTrigger=PropertyChanged}"/>
</Style>
</Window.Resources>
<Syncfusion:SfDataGrid x:Name="datagrid"
AllowEditing="True"
ItemsSource="{Binding ItemsCollection}"
RowStyle="{StaticResource rowStyle}"
AlternatingRowStyle="{StaticResource alternativeRowStyle}" /> |
public class CustomRowStyleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null)
return DependencyProperty.UnsetValue;
if ((value as BusinessObjects).IsChecked)
return new SolidColorBrush(Colors.Green) { Opacity = 0.7 };
return new SolidColorBrush(Colors.AliceBlue);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo cultur
{
throw new NotImplementedException();
}
}
public class AlternativeRowStyleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null)
return DependencyProperty.UnsetValue;
if ((value as BusinessObjects).IsChecked)
return new SolidColorBrush(Colors.Green) { Opacity = 0.7 };
return new SolidColorBrush(Colors.Beige);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo cultur
{
throw new NotImplementedException();
}
} |