We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Set style to primary button

Hello,

In WPF Theme Studio, under Framework Controls, I see a Primary button style.

How do I create a button with a Primary button style in xaml?

Kind regards,

Niels van Strien

1 Reply 1 reply marked as answer

VR Vijayalakshmi Roopkumar Syncfusion Team August 10, 2020 07:10 AM UTC

Hi Niels van Strien 
 
Thank you for contacting Syncfusion Support. 
 
Query : How do I create a button with a Primary button style in xaml? 
 
In our ThemeStudio, by default there is no default support of PrimaryButtonStyle for ButtonAdv controls. But however, you can apply Primary Button style for ButtonAdv by referring the particular PrimaryButtonStyle in application by using the following syntax and change the TargetType as ButtonAdv from Button. 
 
Syntax:[App.xaml] 
 
 
<Application.Resources> 
<ResourceDictionary> 
<!--Referring the Primary Button style for application--> 
<ResourceDictionary.MergedDictionaries> 
<ResourceDictionary Source="PrimaryButton.xaml"/> 
</ResourceDictionary.MergedDictionaries> 
</ResourceDictionary> 
</Application.Resources> 
 
 
 
PrimaryButton.xaml 
 
 
<!--Changing the target type from Button to ButtonAdv--> 
<Style x:Key="WPFPrimaryButtonStyle" TargetType="{x:Type syncfusion:ButtonAdv}"> 
 
<!--Changing the target type from Button to ButtonAdv--> 
<ControlTemplate TargetType="{x:Type syncfusion:ButtonAdv}"> 
 
 
 
Referred style in ButtonAdv:[MainWindow.xaml] 
 
 
<syncfusion:ButtonAdv x:Name="buttonAdv" Content="butonadv" Style="{StaticResource WPFPrimaryButtonStyle}"  Width="100" Height="23" /> 
 
 
 
 
Screenshot: 
 
 
 
 
Please try this solution and let us know if it is helpful. 
 
Note: We have prepared the sample for Dark theme, similarly you can prepare for other material themes by referring the respective theme xaml file of PrimaryButton. The theme file can export it in themestudio . For more information, please refer the following UG link: 
 
 
Regards, 
Vijayalakshmi VR 


Marked as answer
Loader.
Up arrow icon