This is a migrated thread and some comments may be shown as answers.

Using the Office2016 theme resources

1 Answer 325 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Patrick asked on 28 Jan 2020, 05:47 AM

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?

1 Answer, 1 is accepted

Sort by
0
Accepted
Sia
Telerik team
answered on 30 Jan 2020, 10:22 AM

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.
Tags
General Discussions
Asked by
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Sia
Telerik team
Share this question
or