private static void GetDataGridStyles(SfDataGrid dataGrid) { var gridHeaderCellControl = dataGrid.FindResource(typeof(GridHeaderCellControl)) as Style; var gridCell = dataGrid.FindResource(typeof(GridCell)) as Style; if (gridHeaderCellControl == null || gridCell == null) { return; } foreach (Setter setter in gridHeaderCellControl.Setters) { if (setter.Property == GridHeaderCellControl.BackgroundProperty) { gridHeaderBackgroundColor = (Color)ColorConverter.ConvertFromString(setter.Value.ToString()); } else if (setter.Property == GridHeaderCellControl.ForegroundProperty) { gridHeaderForeGroundColor = (Color)ColorConverter.ConvertFromString(setter.Value.ToString()); } } foreach (Setter setter in gridCell.Setters) { if (setter.Property == GridCell.BackgroundProperty) { gridCellBackgroundColor = (Color)ColorConverter.ConvertFromString(setter.Value.ToString()); } } }