Hi,
I'd like to know if it's possible to style the label (change its background color for example) based on the fact if the field has a filter applied to it or not.
I'm trying the following:
private void OnRecordFilterChanged(object sender, RecordFilterChangedEventArgs e){ if (0 < e.RecordFilter.Conditions.Count) { e.RecordFilter.Field.Settings.LabelPresenterStyle = myFilterLabelStyle; }}
My style looks like this:<Style x:Key="myFilterLabelStyleKey" TargetType="{x:Type igDP:LabelPresenter}"> <Setter Property="Background" Value="Yellow" /></Style>In the debugger, I can see the style being set, however there is no effect on the screen. Nothing happens. My grid is also using the Office2010Blue theme. I tried disabling it, and still no effect from this logic.How can I get this to work?Thanks
Hello,
If you put the Style in the XamDataGrid's Resources you don't need to set the BasedOn Property.
Hope this helps you.
Hey Stefan,
I was able to highlight the colum header by doing the following:
I subclassed the Field class and created my own MyField that contains a property IsFiltered.
This property gets evaluated in the codebehind when record filters change.
Then my xaml style looks like this:
<style x:Key="MyLabelPresenterStyle" BasedOn="{x:Static igThemes:DataPresenterOffice2010Blue.LabelPresenter}" TargetType="{x:Type ig:LabelPresenter}">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Field.IsFiltered}" Value="True">
<Setter Property="Background" value="Red"/>
</DataTrigger>
</Style.Triggers>
</style>
Basing it on the theme I use was key to making it look fine. However, now I'm wondering, what happens when the theme changes?
Can this be done in a way to figure out the theme dynamically, and base it on the current theme?
It seems that the approach you use now is the best one for achieving your goal, but if I think of an another one, I will let you know.
The code above (from 8 months ago) now works. I guess my problem was not with the grid. However I want to see if I can now do this via xaml instead via code.
Hi Stefan,
Just revisiting this problem once again.
Is it possible to do this through xaml? I am now using the XamDataGrid from 12.1
I would just like to change the background color of the header when the column is filtering.