<Style x:Key="MyStyle">
<Setter Property="Window.Background" Value="Orange"/>
</Style>
<Button Content="Ok" Style="{StaticResource MyStyle}"/>
Why does the button actually get an orange background, if the setter is specified as Window.Background?
This does not give the TextBlock an orange background:
<TextBlock Style="{StaticResource MyStyle}"/>
Thanks
Neither
ButtonnorWindowactually define theBackgroundproperty, they both inherit it fromControl.So even though you wrote
Window.Background, the setter is actually bound to the property by using theControl.BackgroundPropertyfield which also applied toButton.