Should I include Themes/System.Windows.xaml?

4 posts, 0 answers
  1. n/a
    n/a avatar
    1 posts
    Member since:
    Aug 2019

    Posted 13 Sep 2019 Link to this post

    Hi,

    We're including the NoXaml Telerik DLLs and the Office 2016 theme DLL in our application. We've merged the resources from the various DLLs, including the Themes/System.Windows.xaml resource, as described in Setting a Theme Using Implicit Styles. We've found that this affects the appearance of some non-Telerik controls, such as TextBox, PasswordBox and ScrollViewer. For example, sometimes there are extra borders and sometimes rounded corners are missing (see attached screenshot).

    At the bottom of that same page is a short section called Does a Theme Affect All WPF Controls? that confirms that some native WPF controls are affected by Telerik themes. We would like to avoid this. Could you help by answering the following questions:

    • How exactly do Telerik themes affect the appearance of native WPF controls, and why? Is this expected?
    • What is the best way to avoid this? Setting a Theme on MS Controls says that if we want to style one of the affected WPF controls we should merge the System.Windows.xaml resource dictionary when defining our styles. Will this ensure that everything looks the same as it does without the Telerik theme?
    • We've tried removing just the Themes/System.Windows.xaml resource (while keeping the other Telerik resources) and this seems to fix the appearance of native WPF controls. Is this recommended? What side-effects might this have.

    Thanks.

  2. Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    679 posts

    Posted 16 Sep 2019 Link to this post

    Hello,

    Thank you for the provided picture. 

    The System.Windows.xaml ResourceDictionary contains styles for some of native WPF controls. If you merge this resource, provided that you do not set a style with a higher priority, those controls will receive an implicit style from that ResourceDictionary. You can open the System.Windows.xaml file for the theme that you are using from the Themes.Implicit folder in your UI for WPF installation directory to see all the styles that are within that ResourceDictionary. 

    If you don't want the native WPF controls' styles to be altered, you can simply avoid merging the System.Windows.xaml ResourceDictionary. This will not cause any side effects for the UI for WPF controls. 

    I hope you find this helpful.

    Regards,
    Vladimir Stoyanov
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Jason D
    Jason D avatar
    130 posts
    Member since:
    Jan 2011

    Posted 03 Oct 2019 Link to this post

    Note that if you don't include the file, some controls will not show in the Designer, such as the Tab Control. You don't need to include it in your application, but it does need to be accessible at design time. For example:
    https://antonymale.co.uk/design-time-resources-in-wpf.html

    Here is how mine is set up:

        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="../src/Themes/System.Windows.xaml"/>
            <ResourceDictionary Source="pack://application:,,,/src/Themes/Telerik.Windows.Controls.xaml"/>
            <ResourceDictionary Source="pack://application:,,,/src/Themes/Telerik.Windows.Controls.DataVisualization.xaml"/>
            <ResourceDictionary Source="pack://application:,,,/src/Themes/Telerik.Windows.Controls.Input.xaml"/>
            <ResourceDictionary Source="pack://application:,,,/src/Themes/Telerik.Windows.Controls.Navigation.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

  4. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2444 posts

    Posted 08 Oct 2019 Link to this post

    Hello Jason,

    Thank you for sharing the additional information.

    Regards,
    Martin Ivanov
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top