Hi
I am new to the telerik world. I am currently working in a code base that uses a mixture of Telerik winforms (15.1.331) and telerik wpf controls (15.1.401). The application has a custom tssp file for winform elements that sets elements in a style. It also uses builtin Expression-DarkTheme for all wpf controls. My goal is to make both winforms buttons and wpf buttons look the same. I would like to know what is the best approach?
Is there a way to create a wpf button theme from the winform radbutton style in the tssp file and apply it across the solution?
Thanks
Venkat
5 Answers, 1 is accepted
Since the Xaml styles and the xml in the custom style files are quite different in their structure there is no straight forward conversion between them. In order to achieve your requirement you will need to manually create the styles for the WPF button. You can use Expression Blend to create the styles or write them manually in the application's resources.
Regards,
Martin
Telerik
Hi Martin
Thank you for the reply. Is it possible for you to share a wpf button template example. Also if possible an example on how to add a customized button template, but leave the Expression-DarkTheme as default for the other elements.
Thanks
Venkat
I attached a small example that demonstrates several of our controls with the Expression_Dark theme and a extracted, and customized template for the RadButton control. Note that I am using the Implicit Styles theming mechanism to apply the theme. I also commented the changes to the button's template that I've made. Basically, I used Visual Studio to extract the Style (including the template) of the button and placed it into a ResourceDictionary file. Then, I modified the style and merged the resource dictionary into the application's resources (the App.xaml file).
Please give the project a try and let me know if it helps.
Regards,
Martin
Telerik
Hi Martin
As i was mentioning since we have a combination of wpf and winforms we don't have App.xaml, we set the wpf theme in program.cs too. 1) So how do i add this custom button xaml in program.cs
2) I have many wpf buttons within my software. So i don't want to do Style="{StaticResource RadButtonStyle1} in every button xaml tag. Is there a way to set this once and apply to all my buttons
You can add the button using an implicit style. This is a style that is defined without an x:Key which applies it to all elements of the specified TargetType in the scope where the style is added. For example, if you have a UserControl with 10 Button elements and you define the following style, the style will be applied automatically to all 10 buttons.
<
UserControl.Resources
>
<
Style
TargetType
=
"Button"
>
<
Setter
Property
=
"Background"
Value
=
"Red"
/>
</
Style
>
<
UserControl.Resources
>
<
UserControl.Resources
>
<
ResourceDictionary
Source
=
"RadButtonCustomStyle.xaml"
/>
<
UserControl.Resources
>
wpfHost.MyUserControl.Resources.MergedDictionaries.Add(
new
ResourceDictionary { Source =
new
Uri(@
"/<YourDllName>;component/RadButtonCustomStyle.xaml"
, UriKind.Relative) });
Please let me know if this information helps.
Regards,
Martin
Telerik