Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
149375 | Nov 23,2019 07:09 PM UTC | Nov 28,2019 05:48 AM UTC | WPF | 4 |
![]() |
Tags: SfDataGrid |
<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();
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.