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

How to override theme for custom control

1 Answer 293 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jerry
Top achievements
Rank 1
Jerry asked on 12 Jul 2016, 03:14 PM

In our Silverlight app, we have a container view that defines a merged dictionary that points to the following themes:

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Telerik.Windows.Themes.Metro;component/Themes/System.Windows.xaml"/>
<ResourceDictionary Source="/Telerik.Windows.Themes.Metro;component/Themes/Telerik.Windows.Controls.xaml"/>
<ResourceDictionary Source="/Telerik.Windows.Themes.Metro;component/Themes/Telerik.Windows.Controls.Input.xaml"/>
<ResourceDictionary Source="/Telerik.Windows.Themes.Metro;component/Themes/Telerik.Windows.Controls.Navigation.xaml"/>
<ResourceDictionary Source="/Telerik.Windows.Themes.Metro;component/Themes/Telerik.Windows.Controls.GridView.xaml"/>

 

All the user control views that display in the container inherit these themes.

The problem we have is that when we insert one of our custom controls onto any of these user control views, the custom control doesn't appear correct. This custom control is made up of a textbox, popup and button. The textbox backgrond appears transparent instead of grey.

Is there a way to override our custom control look and feel from what the above themes are doing to this control?

 

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 13 Jul 2016, 09:50 AM
Hi Jerry,

If I understand you correctly, the way to prevent a certain control from being styled by the Telerik themes, but preserve the style for the rest of the application, is to set specific Style for your custom control.

You can extract the default windows styles for the components you are using (in your case TextBox, Button and Popup) and integrate them in the UserControl Resources. But keep in mind that setting a custom style on any control and not Basing it on the Telerik styles will result in completely overriding the theme style for it and applying the specified style.

The other approach is to create a style for the whole control and define its children inside, with references to their native styles (they need to be present as resources as well). This way you can have one style tag in your application resources with a target your control which will style all its instances.

You can also consider to remove the default Telerik theming of the native WPF controls as TextBox, Button, etc. To do that just delete the ResourceDictionary that points to the System.Windows.xaml file.

You can review this article in MSDN for default ControlTemplates of most of the native controls and this thread in Stack Overflow about extracting a default ControlTemplate.

Regards,
Martin
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
General Discussions
Asked by
Jerry
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or