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

Default RadWindow style is not being overridden by custom style

2 Answers 51 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
YBOT
Top achievements
Rank 1
Veteran
YBOT asked on 06 Jan 2021, 09:37 AM

The style for my RadWindows is not being overriden from the default theme. I don't have the same issue with other telerik controls like RadButton, the style gets set fine for them. Why is this happening? How can I set a RadWindow style?

MyWindow.xaml

<telerik:RadWindow
    x:Class="MyWindow"
    Header="My Window"
    <Grid>
     // window content
            <telerik:RadButton
                Content="OK" />
            <telerik:RadButton
                Content="Cancel" />
        </StackPanel>   
    </Grid>
</telerik:RadWindow>

 

 

My App.Xaml file contains MergedDictionaries

<ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/Telerik/RadButton.xaml" />
        <ResourceDictionary Source="pack://application:,,,/Telerik/RadWindow.xaml" />
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

 

Here are the individual xaml files

RadWindow.xaml

<ResourceDictionary
 
    <Style TargetType="{x:Type telerik:RadWindow}">
        <Setter Property="Background"
                Value="Green" />
    </Style>
</ResourceDictionary>


RadButton.xaml

<ResourceDictionary
     
    <Style TargetType="{x:Type telerik:RadButton}">
        <Setter Property="Background"
                Value="Blue" />
 
    </Style>
</ResourceDictionary>

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Masha
Telerik team
answered on 07 Jan 2021, 06:35 AM

Hello Toby,

Thank you for contacting us.

If you use RadWindow as a custom UserControl, you will need to apply a new style targeting the custom control and base it on the default RadWindowStyle. You should add the following implicit style in your App.xaml file under the merged dictionaries:

  <Style TargetType="local:MyWindow" BasedOn="{StaticResource RadWindowStyle}" /> 

The important part is to set the TargetType property to the type of the UserControl.

I hope this helps.

Regards,
Masha
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/.

0
YBOT
Top achievements
Rank 1
Veteran
answered on 07 Jan 2021, 03:32 PM
Thanks.
Tags
General Discussions
Asked by
YBOT
Top achievements
Rank 1
Veteran
Answers by
Masha
Telerik team
YBOT
Top achievements
Rank 1
Veteran
Share this question
or