Declined
Last Updated: 01 Apr 2022 11:23 by ADMIN
LindenauAtSOG
Created on: 29 Nov 2021 07:38
Category: UI for WPF
Type: Feature Request
1
Add a way to disable Styles for "standard controls"

Right now, it is not easy to disable styles for standard controls like Button.
Especially when using NoXaml.

You have to create an Empty style on Application level for the control to "rewind" its style.
I do believe this kind of style drags down performance of controls when unloading, since it causes StyleChanged events.

 

Some explanation about performance (how things work to my understanding). Might be BS, but I spend a few hours debugging through .net code to get this idea:

Issue is, that when control is unloaded, its not part of the logical / visual tree of the application anymore, so it falls back to styles defined on assembly level.
e.g. Themes/Generic.xaml.  So the empty styles defined on Application level do not count anymore, but the ones you defined in your theme.
This can be observed on RadTabbedWindow. When unloading pages (like switching between them), controls fall back to the styles defined in the theme from Telerik.Windows.Controls.Navigation, because they are still children of that page.
You can observe this behaviour if you set a Breakpoint in FrameworkElement.OnStyleChanged before unloading a control tree.

 

 

If you'd remove the System.Windows.xaml from your theme-dictionaries so that one can decide to merge those styles or not, that would be great.

4 comments
ADMIN
Vicky
Posted on: 06 Dec 2021 09:50

Hi Christian,

It appears that this is a typical feature of the implicit theming mechanism of the .NET Framework. If you have already addressed it at the Microsoft's GitHub repo and they take it into consideration, we will be able to update our mechanism respectively.

Until then, I believe the only suggestion is to switch to StyleManager if the performance using this theming mechanism is satisfactory for you.
If there is anything else I can assist you with, do not hesitate to contact me.

Best Regards,
Vicky
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

LindenauAtSOG
Posted on: 06 Dec 2021 08:14

Hi Vicky,

we do know how to "reset" back to standard styles. The main issue that we have is, that this comes with a performance drawback.

When you unload controls, like unloading a TabPage you will get style changed events.
Since the page is not in the visual nor logical tree of the application anymore.

This is because the styles source, which is located in app.xaml is not valid anymore, so it will fallback to your defined styles.
Those StyleChanged-Events can cause unloading of TabPages take multiple seconds. I blame the .net-Framework for this, because I do not believe that StyleChanged events should happen like this when unloading a control, it should invalidate and reevaluate when "loading" the control again, so it will effectively not get any changed event, but thats a different story I try to adress ad Microsoft on GitHub right now.



ADMIN
Vicky
Posted on: 03 Dec 2021 13:06

Hi Christian,

One of our main goals when it comes to the styling mechanisms we provide is to ensure the consistent look and feel for all Telerik controls. That is the reason why we support styles for the MS controls (referred by you as "standard controls") which are internally used as part of the default ControlTemplates of the more complex Telerik controls.

The above-said excludes the possibility of removing the System.Windows.xaml file from our theme dictionaries.

I am not sure of your exact scenario. I will need more information about it. If we take the example given about the TabbedWindow control:

  1.  Do you want it to contain an MS Button which has the MS Style applied?
  2. Or do you want all MS controls used in its ControlTemplate to have the MS Styles?

If the answer to the first question is yes, then you have two options depending on the theming mechanism that you prefer to use.

  • Option 1 - Use StyleManager. For this Telerik theming mechanism all standalone native controls that we support theme-aware styling for will not automatically receive it. By standalone native controls I mean those which are not part of our controls' default ControlTemplates. For them, as stated in the Use StyleManager to Apply Theme on MS Controls article, you should manually set the corresponding theme.
  • Option 2 - Use NoXaml without merging the System.Windows.xaml file in your Application Resources. There is one more thing that needs to be done here - overriding the styles for all native controls supported by the Telerik theming mechanism. Of course, all native controls which you will use as a standalone ones and that you do not want to have Telerik styles. This is recommended to be done in a separate ResourceDictionary that needs to be merged in the Application Resources:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style TargetType="{x:Type Button}"/>
    <Style TargetType="{x:Type ScrollViewer}"/>
    <Style TargetType="{x:Type CheckBox}"/>
    <Style TargetType="{x:Type TextBox}"/>
    <Style TargetType="{x:Type RadioButton}"/>
    <Style TargetType="{x:Type ListBox}"/>
    <Style TargetType="{x:Type PasswordBox}"/>
    <Style TargetType="{x:Type RepeatButton}"/>
    <Style TargetType="{x:Type ToolTip}"/>
    <Style TargetType="{x:Type Hyperlink}"/>
    <Style TargetType="{x:Type StatusBar}"/>
    <Style TargetType="{x:Type GridSplitter}"/>
    <Style TargetType="{x:Type Separator}"/>
</ResourceDictionary>

<!--And then in your App.xaml-->

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <!--<ResourceDictionary Source="/Telerik.Windows.Themes.Office2019;component/Themes/System.Windows.xaml"/>-->
            <ResourceDictionary Source="/Telerik.Windows.Themes.Office2019;component/Themes/Telerik.Windows.Controls.xaml"/>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Office2019;component/Themes/Telerik.Windows.Controls.Input.xaml"/>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Office2019;component/Themes/Telerik.Windows.Controls.Navigation.xaml"/>
            <ResourceDictionary Source="/NativeControlsStyles.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

I hope you find the above information helpful.

Best Regards,
Vicky
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

LindenauAtSOG
Posted on: 29 Nov 2021 07:40
Ffor observing the mentioned behaviour, you also need an empty style in app resources like <Style TargetType="{x:Type Button}" /> to revert the Telerik Button Style