Change Filterbehaviour breaks formatting

Hi,

in the documentation I found that I can change the filter to CheckboxFilter using a style.
I did this - but it ended wiht an unusable nasty looking popup.
<Style x:Key="filterControlStyle" TargetType="syncfusion:GridFilterControl" BasedOn="{StaticResource {x:Type syncfusion:GridFilterControl}}">
<Setter Property="FilterMode" Value="CheckboxFilter" />
</Style>
No matter if I used "BasedOn" (which often helps) or not I get the same result.
I just guess this is a problem with theming.



6 Replies 1 reply marked as answer

MA Mohanram Anbukkarasu Syncfusion Team June 3, 2021 11:42 AM UTC

Hi ManniAT, 

Thanks for contacting Syncfusion products.  

You can resolve this by using BasedOn for the style as shown in the following code example.  

Code example :  

App.Xaml 
 
<Application.Resources> 
    <ResourceDictionary> 
        <ResourceDictionary.MergedDictionaries> 
            <ResourceDictionary Source="/Syncfusion.Themes.MaterialDark.WPF;component/SfDataGrid/SfDataGrid.xaml"/> 
        </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 
</Application.Resources> 

Window.Xaml 
<Window.Resources> 
 
    <Style x:Key="filterControlStyle" TargetType="syncfusion:GridFilterControl" BasedOn="{StaticResource SyncfusionGridFilterControlStyle}"> 
        <Setter Property="FilterMode" Value="CheckboxFilter" /> 
    </Style> 
</Window.Resources> 
<Grid> 
    <syncfusion:SfDataGrid Name="dataGrid" 
                           AllowFiltering="True" 
                           FilterPopupStyle="{StaticResource filterControlStyle}" 
                           ItemsSource="{Binding OrdersListDetails}"/> 
</Grid> 

 


Please let us know if you require further assistance from us.  

Regards, 
Mohanram A. 



MA ManniAT June 3, 2021 12:08 PM UTC

Hi,

thank you for the answer.
But this helps only partial, because when I change the theme I have to adapt this everywhere in my XAMLS.
Of course I could do this in a global style but what if I want to change the theme at runtime?


MA Mohanram Anbukkarasu Syncfusion Team June 4, 2021 01:04 PM UTC

Hi ManniAT,

Thank you for the update. 

The reported problem has been resolved only by the sample level changes. Please refer below steps to resolve the problem,

Step 1: Create the new resource dictionary and then add your customized control style here. And should add this resource dictionary into the Application.Resources.


Step 2: Add the necessary resources in the Application.Resources. Please refer the below screenshot,
 
Step 3: If you want to change the theme at runtime. Then you should clear the merge dictionaries and add them like below.


Step 4: For merging the resources for the window you should give the style like below,


Please find the modified sample from below, 
Sample Link : https://www.syncfusion.com/downloads/support/forum/166021/ze/Sample-672469839

Please let us know if you have any concerns in this.

Regards,
Mohanram A. 



MA ManniAT June 4, 2021 06:26 PM UTC

Thank you for the solution and your help.
Unfortunately this is not a practical approach - at least not for my needs.
I currently try to migrate an application from a competitors control library to Syncfusion.
With the competitor I also have a "SkinManager" but this is not base on a window or something - I just select the Theme statically - the first time in a viewmodel created from Application.Startup.
OK - no big deal to have a little code behind in the main window - so this is not really a problem.
I could reference App.MainWindow and call a "theme switcher" there.
By the way - to switch a theme I just call ManagerClass.SetTheme() - DONE.
The only thing I have to do with resource directories is that I can define my own color / brush resources depending on the selected theme.

I then use this brush to display "Highlighted text" or so.
But back to your solution and why it is not usable for me.
Also differing from the competitor your GridColumns have no DPs for tooltip.
To translate a column from
I hav to use something like this

And here the problem starts - since I have to use a style this will again break theming.
Unless I move this style to a resource dictionary - which is not really possible with a large number of GridColums in several views.
The same for a TabControlExt. It is databound. With the competitor I just use a datatemplate.
Since TabControlExt has no HeaderTemplate (just an EditHeaderTemplate) I must again use a style.
Which ends with:

And again - theming broken.
The other problem with your solution is that I have to "guess" (at least your naming conventions seem to be consistent) the resource key.
What worked was

Finally I stumbled over some MSControl elements which I didn't know they've been used.
Conlusion:
It looks like a lot of things work when I set the theme a startup.
For an example the TabItemExt (needed to set the header) works when I set the theme at startup. Also the GridColumns look like expected.
So it looks as if I have to let the user restart the application when he likes to user a different theme.
And hope that not to much problems like with the Filter have to be solved "somehow".
Finally - althoug I'm not happy with your theming and the missing DPs... I really like your support.
You are fast - give clear an detailed answers - you are even including sample solutions!!
Thank you!


MA ManniAT June 7, 2021 12:30 PM UTC

So finally - based on your suggestions I got a solution which makes the things at least "useable".

I use "SfSkinManager.SetTheme..." for most of my controls.

Next I created 2 Resource dictionaries.
One for light and one for dark.
There I added the (syncfusion) resouce dictionaries I want to change styles from in a merged dictionary.
Looks like this for an example:



Next I added a resouce dictionary for dependent resources like this for an example:


And finally (on xaml) I add those two resources in App.xaml like this:


In code behind I did something like this:


This works as expected and having the syncfusion xaml files in app.xaml enables me to do "BasedOn" directl in the source of my views like this:



So this seems to solve my problems. Sorry for the stupid questions, but I'm migration a big app from a competitors control suite to telerik and this is sometimes a bit tricky,
becuase I'm used to their "lookless controls" where everything is completely seperated in Styles for the look and Bindings (dependency properties) for the content.


Marked as answer

MA Mohanram Anbukkarasu Syncfusion Team June 7, 2021 01:43 PM UTC

Hi ManniAT, 

Thanks for the update.  

We are glad to know that you have found a solution for the problem. Please let us know if you require any other assistance from us.  

Regards, 
Mohanram A. 


Loader.
Up arrow icon