Hi,
is it possible somehow style filter row drop down? I need to change foreground and background colors there.
Thanks!
Ondřej Svoboda
|
public MainWindow()
{
InitializeComponent();
this.dataGrid.RowGenerator = new CustomRowGenerator(this.dataGrid);
}
public class GridFilterRowCellExt : GridFilterRowCell
{
public GridFilterRowCellExt()
: base()
{ }
/// <summary>
/// Opens the FilterOptionPopup with the FilterOptionList.
/// </summary>
public override void OpenFilterOptionPopup()
{
base.OpenFilterOptionPopup();
var styleListBox = new Style(typeof(ListBox));
styleListBox.Setters.Add(new Setter
{
Property = BackgroundProperty,
Value = Brushes.SkyBlue
});
styleListBox.Setters.Add(new Setter
{
Property = ForegroundProperty,
Value = Brushes.Blue
});
this.FilterOptionsList.Style = styleListBox;
}
}
public class CustomRowGenerator : RowGenerator
{
public CustomRowGenerator(SfDataGrid dataGrid)
: base(dataGrid)
{
}
/// <summary>
/// Return the Custom FilterRowCell
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns>GridCell</returns>
protected override GridCell GetGridCell<T>()
{
//If the Cell is FilterRowCell return custom FilterRowCell
if (typeof(T) == typeof(GridFilterRowCell))
return new GridFilterRowCellExt();
return base.GetGridCell<GridCell>();
}
} |
Works OK, thanks.