Using the Office2016 theme resources

2 posts, 1 answers
  1. Patrick
    Patrick avatar
    498 posts
    Member since:
    Aug 2012

    Posted 27 Jan Link to this post

    Hello,

    I'm trying to use the Office2016 theme colors in one of my controls.

    To do this, I've used the following XAML:

    <ResourceDictionary
      xmlns:tk="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
      xmlns:osctrl="clr-namespace:OrdinaSoft.Windows.Controls">
     
      <ResourceDictionary.MergedDictionaries>
        <tk:Office2016ResourceDictionary />
      </ResourceDictionary.MergedDictionaries>
     
      <Style TargetType="osctrl:osRadGroupBox">
        <Setter Property="BorderBrush"           Value="{StaticResource BasicBrush}" />
        <Setter Property="HeaderBrush"           Value="{StaticResource AccentBrush}" />
        <Setter Property="HeaderForeground" Value="{StaticResource MainBrush}" />
      </Style>
     
    </ResourceDictionary>

     

    Unfortunately, this doesn't work! When I run the application I have the following error: "Cannot find resource named 'BasicBrush'. Resource names are case sensitive."

    If I look with the debugger just after the resource dictionary is loaded, I can see the resources defined, including BasicBrush!

    If I define myself the brushes, with "<Brush x:Key="AccentBrush">#FF2A579A</Brush>" for example, it works correctly.

    Why can't I use the Office2016 resources directly?

  2. Answer
    Sia
    Admin
    Sia avatar
    756 posts

    Posted 30 Jan Link to this post

    Hello,

    I would suggest a different approach, which may seem more complex but actually is the same as the one which we use to create our themes.

    Instead of trying to set brushes as StaticResource, just use them as follows:

    <Style TargetType="osctrl:osRadGroupBox">
        <Setter Property="BorderBrush" Value="{tk:Office2016Resource ResourceKey=BasicBrush}" />
        <Setter Property="HeaderBrush" Value="{tk:Office2016Resource ResourceKey=AccentBrush}" />
        <Setter Property="HeaderForeground" Value="{tk:Office2016Resource ResourceKey=MainBrush}" />
    </Style>

    I hope this helps.

    Regards,
    Sia
    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