我想要做的事情是:
<Application.Resources>
<Style TargetType="{x:Type UIElement}">
<Setter Property="Opacity"
Value=".1" />
</Style>
</Application.Resources>
我希望能够为任何类型(不仅限于某些最终的具体UI类型)设置样式。我并不寻求最佳实践,这更像是一个需要思考的问题。
我注意到WPF不会给TargetType
中指定的任何超类(如UIElement
、FrameworkElement
等等)设置样式。只有当TargetType
等同于具体的UI类(如Button
、Rectangle
)时才会设置样式。