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

How to use telerik winform radbutton style for a wpf button

5 Answers 319 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
Venkat
Top achievements
Rank 1
Venkat asked on 25 Aug 2015, 10:40 PM

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

Sort by
0
Martin Ivanov
Telerik team
answered on 27 Aug 2015, 07:40 AM
Hi Venkat,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Venkat
Top achievements
Rank 1
answered on 31 Aug 2015, 06:10 PM

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

0
Martin Ivanov
Telerik team
answered on 01 Sep 2015, 08:50 AM
Hello 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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Venkat
Top achievements
Rank 1
answered on 15 Sep 2015, 12:27 AM

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

0
Accepted
Martin Ivanov
Telerik team
answered on 17 Sep 2015, 12:03 PM
Hi Venkat,

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>
You can merge add the resource dictionary in the Resources of the UserControls hosted in your WinForms application.
<UserControl.Resources>
    <ResourceDictionary Source="RadButtonCustomStyle.xaml"/>
<UserControl.Resources>
You can also do that in code using the Resources property of the UserControl.
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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Buttons
Asked by
Venkat
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Venkat
Top achievements
Rank 1
Share this question
or