Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reset inherited WPF style?

In the App.xaml portion of my application I have a ResourceDictionary element that targets things like DataGridColumnHeader and DataGridCell and applies custom styling to them. These definitions are global (in that they don't use a x:key - they apply to all instances of the type).

Is it possible to completely reset the style of these types to the 'base' Aero theme (or whatever theme is currently in use) for use in a subsection of my application?

I've tried using

<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
    </Style>

Which doesn't seem to do anything, as I'm guessing its just inheriting itself.

like image 516
maxp Avatar asked May 28 '15 09:05

maxp


1 Answers

There are 2 ways to reset the style:

  1. Set the style property of the element to {x:Null}. You will have to do this on every element.

    <Button Height="50" Style="{x:Null}"></Button>
    
  2. Define an empty style in the resources of the element containing the elements you want to reset. Don't specify BasedOn, otherwise it will inherit all properties and does not reset them to standard (as you correctly noticed).

    <Style TargetType="{x:Type DataGridColumnHeader}">
    </Style>
    
like image 125
Domysee Avatar answered Nov 17 '22 19:11

Domysee