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

Theme inheritance

1 Answer 37 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Murray
Top achievements
Rank 2
Murray asked on 12 Jan 2012, 09:43 PM
Hi

We are using your Expression_Dark theme (customers love it!) and to apply the theme to non-Telerik controls I handle it in ResourceDictionaries like this...

<Style TargetType="TextBox" telerik:StyleManager.BasedOn="Expression_Dark">

This works great, however on certain forms we might want to set specific properties of a TextBox like margins.

<UserControl.Resources>
        <Style TargetType="TextBox">
            <Setter Property="Margin" Value="5"/>
        </Style>
    </UserControl.Resources>


If we use an inline Usercontrol.Resources declaration, the declaration completely ignores anything set in the ResourceDictionary!

Any idea on how to get both?



1 Answer, 1 is accepted

Sort by
0
Murray
Top achievements
Rank 2
answered on 13 Jan 2012, 02:50 PM
Found the answer.

In your ResourceDictionary.xaml:
Add a Key to what you originally wanted to be global.
<Style TargetType="TextBox" telerik:StyleManager.BasedOn="Expression_Dark"  x:Key="Main">
        <Setter Property="AllowDrop" Value="true"/>
        <Setter Property="IsEnabled" Value="true"/>
        <Setter Property="AcceptsReturn" Value="false"/>
        <Setter Property="TextWrapping" Value="NoWrap"/>
        <Setter Property="IsReadOnly" Value="false"/>
    </Style>

Create an empty global style and base it on the key.
<Style TargetType="TextBox" BasedOn="{StaticResource Main}">
 </Style>

This will still use everything in the keyed style globally.

Then on the page.xaml you want to add additional styles globally to just that page (like Margins) do this:
<UserControl.Resources>
        <Style TargetType="TextBox" BasedOn="{StaticResource Main}">
            <Setter Property="Margin" Value="80" />
        </Style>
    </UserControl.Resources>

This will give you everything in the ResourceDictionary PLUS stuff declared locally!

Tags
General Discussions
Asked by
Murray
Top achievements
Rank 2
Answers by
Murray
Top achievements
Rank 2
Share this question
or