Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
144591 | May 13,2019 06:28 PM UTC | May 29,2019 04:27 AM UTC | WPF | 6 |
![]() |
Tags: SfDataGrid |
public class CustomStyleSelector : StyleSelector
{
public override Style SelectStyle(object item, DependencyObject container)
{
var businessObject = item as BusinessObjects;
Style cellStyle1 = new Style(typeof(GridCell));
cellStyle1.Setters.Add(new Setter(GridCell.BackgroundProperty, newSolidColorBrush(Colors.YellowGreen) { Opacity = 0.2 }));
Style cellStyle2 = new Style(typeof(GridCell));
cellStyle2.Setters.Add(new Setter(GridCell.BackgroundProperty, newSolidColorBrush(Colors.CornflowerBlue) { Opacity = 0.2 }));
if (businessObject != null)
{
if (businessObject.EmployeeGender == "Male")
return cellStyle1;
else
return cellStyle2;
}
return base.SelectStyle(item, container);
}
} |
var businessObject = item as BusinessObjects;
bool isSelected = dataGrid.SelectedItems.Contains(businessObject); |
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.