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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to override style regardless of current theme?

Thread ID:

Created:

Updated:

Platform:

Replies:

119772 Jul 30,2015 07:59 AM UTC Aug 16,2017 09:26 AM UTC WPF 7
loading
Tags: SkinManager
Soon Hui Ngu
Asked On July 30, 2015 07:59 AM UTC

I have a grid where I want all buttons to have a certain margin. All other style properties should be as if no custom style was applied, i.e. the still from the currently applied Theme.

Using something like below code doesn't work, as it completely ignores the theme's style.

    <Grid.Resources>
        <Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
            <Style.Setters>
                <Setter Property="Margin" Value="3" />
            </Style.Setters>
        </Style>
    </Grid.Resources>

Resources such as http://help.syncfusion.com/ug/wpf/index.html#!documents/overridesyncfusionthemes.htm show how to override one specific style. This is far too complicated for me, since I'd need to 
1) include all possible themes
2) override each of these theme's style, all in the exact same manner
3) use code-behind to determine which theme is currently applied, and select the style based on this

Is there really no easier way to achieve this?

Muthukumar A [Syncfusion]
Replied On July 30, 2015 11:46 AM UTC

Hi Soon,

Thanks for contacting Syncfusion.

In order to override theme from package you should override specific Style key provided in package.

Instead of BasedOn="{StaticResource {x:Type Button}}" ,
please use   BasedOn="{StaticResource MetroButtonStyle}"

Here, MetroButtonStyle is the key provided in Source. The naming convention of Style key is,

Themename+ControlName+ Style. For example MetroDateTimeEditStyle.

We have created a simple sample for this, and please have it from following location

Sample link: 
SkinSample_119772


Please let us know in case of any further assistance.

Regards,
Muthukumar A

Soon Hui Ngu
Replied On July 31, 2015 12:52 AM UTC

The point of my question is that I don't want to override one specific style; I want the user to be able to select a theme and the override to be applied to whichever style is associated with this theme.

Sugapriya Mariappan [Syncfusion]
Replied On July 31, 2015 10:07 AM UTC

Hi Soon,

We have modified our last updated sample which tries to meet your requirement. In this sample we have added the theming Dictionary for the Button control into the application to acquire all the properties of the base style and then we have overrided each style using BasedOn Property. And also based on theme selection at the runtime, overrided style for the corresponding theme will be applied.

Please download the sample from the following link
Sample link:SkinSample_119772

Please let us know if you need any other assistance

Regards,
M.Sugapriya

Eric Gurney
Replied On August 10, 2017 04:28 PM UTC

How would I accomplish the same thing using SfSkinManager themes?

Thanks,

Eric



Vinothini [Syncfusion]
Replied On August 11, 2017 07:27 AM UTC

Hi Eric, 
 
You requirement can be accomplished by using Theme studio. In ThemeStudio, you can customize the color of the predefined themes and export your customized themes for your application. The user guide for Theme Studio is available in the below link. 
 
 
Check with the above link and let us know if you need any further assistance. 
 
Regards, 
Vinothini.R 


Eric Gurney
Replied On August 16, 2017 12:07 AM UTC

The merge and export exports a very small XAML file with hardly anything in it.  How do I get the same xaml pieces I see when I don't have that checked into one file?


Vinothini [Syncfusion]
Replied On August 16, 2017 09:26 AM UTC

Hi Eric, 
 
Thank you for your update. 
 
We faced some problem in “Merge and Export” and it is fixed internally. A support incident has been created under your account to provide you the solution. Please log on to our support website to check for further updates.  
 
   
Regards, 
Vinothini.R 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;