Filter row drop down styling
Hi,
is it possible somehow style filter row drop down? I need to change foreground and background colors there.
Thanks!
Ondřej Svoboda
SIGN IN To post a reply.
3 Replies
MA
Mohanram Anbukkarasu
Syncfusion Team
June 30, 2021 01:51 PM UTC
Hi Ondřej Svoboda,
Thanks for contacting Syncfusion support.
You can achieve your requirement to change the background and foreground color of the filter row dropdown by creating custom GridFilterRowCell as shown in the following code example.
Code example :
|
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>();
}
} |
Sample link : https://www.syncfusion.com/downloads/support/forum/166779/ze/SfDataGrid_FilterRow81390421
Please let us know if you require any other assistance from us.
Regards,
Mohanram A.
OS
Ondrej Svoboda
July 1, 2021 11:05 AM UTC
Works OK, thanks.
MA
Mohanram Anbukkarasu
Syncfusion Team
July 1, 2021 03:21 PM UTC
Hi Ondřej Svoboda,
Thanks for the update.
We are glad to know that the provided solution worked at your end. Please let us know if you require any other assistance from us. We are happy to help you.
Regards,
Mohanram A.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
OS Ondrej Svoboda
- Jun 29, 2021 03:26 PM UTC
- Jul 1, 2021 03:21 PM UTC