Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6187061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:59:47+00:00 2026-05-24T01:59:47+00:00

How do I change what WPF’s idea of the default style for a control

  • 0

How do I change what WPF’s idea of the default style for a control is? And why is this happening in the first place? In the below XAML, I declare a Style for Button, and then further declare a new Style that overrides one of the setters called “HugeBut”. I would expect that HugeBut is implicitly BasedOn my new un-named style, but apparently it is not;

<Window.Resources>
  <Style TargetType="{x:Type Button}">
    <Setter Property="Foreground" Value="Black"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Button}">
          <Border Background="Red">
            <ContentPresenter/>
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <!-- badness -->
  <Style TargetType="{x:Type Button}" x:Key="HugeBut">
    <Setter Property="Foreground" Value="Yellow"/>
  </Style>

  <!-- works, but I do not want to explicitly set the based-on. -->
  <Style TargetType="{x:Type Button}" x:Key="HugeBut" BasedOn="{StaticResource {x:Type Button}}">
    <Setter Property="Foreground" Value="Yellow"/>
  </Style>
</Window.Resources>

<Button Content="Regular" />
<Button Content="huge!" Style="{StaticResource HugeBut}"/>

You would expect two red buttons, one with black text and one with yellow, but Style HugeBut inherits all of the values that I did not specify in my unnamed style from the system default theme for Button (Aero in my case).

What can I do to change this behavior?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:59:50+00:00Added an answer on May 24, 2026 at 1:59 am

    It appears that the answer is here:

    http://wpfthemereplacer.codeplex.com/

    From the site description:

    This library allows users to provide their own resource dictionaries
    to replace the default theme dictionaries loaded by WPF. This makes it
    so you don’t have to decorate custom styles with
    BasedOn=”{StaticResource {x:Type …}}” when your own custom theme is
    being used in your application. It also makes it so if you have custom
    controls that just provide enhanced capability and don’t need to
    replace the the style, you don’t need to define a new style or
    override the DefaultStyleKey when you create the custom control.

    This is exactly what I’m looking for. This will allow me to use Styles as they are meant to be used across an app that has been extensively “re-themed”, rather than theme-ing by setting global styles (and then deal with tracking down bits of code that are missing BasedOn, or cannot deal with it at all due to WPF bugs and other constraints)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to change image for WPF trigger 'IsMouseOver' for button, the control
I have a custom WPF Line, that I whant to change the Style when
I'm using Syncfusion to change the style of my WPF application to the Office
Is there a way to change the default background of WPF/Silverlight designer (Cider)? Or
Is it possible to change the default template of each ASP.NET server control? In
I want to change the style of the button on the basis of if
What would be the bast way to change the orientation of the WPF treeview.
A bit new with WPF...It seems like not matter what I change with horizontal
How can I change default Generate Method Stub behavior in Visaul Studio to generate
Is there a way to change a WPF assembly icon from code? I'm not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.