3

Here's something I want to do:

<Application.Resources>
    <Style TargetType="{x:Type UIElement}">
        <Setter Property="Opacity"
                Value=".1" />
    </Style>
</Application.Resources>

So that I can style any type (not just some final concrete UI type). I am not looking for best practices, its more of a question to ponder.

I noticed that WPF does not style any super class specified in TargetType (UIElement, FrameworkElement, etc etc). It styles only if the TargetType equates to the concrete UI class (Button, Rectangle).

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72

1 Answers1

2

if you just want to define a base Style, you can however use BasedOn property.

<Style TargetType="FrameworkElement" x:Key="ElementBase">
    <Setter Property="Height" Value="24"/>
</Style>

<Style TargetType="TextBlock" BasedOn="{StaticResource ElementBase}">
</Style>

It is a little bit more work, but maybe it helps.

exception
  • 223
  • 1
  • 4
  • 10