KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I was looking at this question and noticed that placing an implicit TextBlock style in Application.Resources applies that style to all TextBlocks, even those inside other controls such as Buttons , ComboBoxes , etc <Application.Resources> <Style TargetType="{x:Type TextBlock}"> <Setter Property="Foreground" Value="Blue" /> </Style> </Application.Resources> Placing the implicit style in Window.Resources does not cross control template boundaries , so things like Buttons and ComboBoxes maintain their default black text. <Window.Resources> <Style TargetType="{x:Type TextBlock}"> <Setter Property="Foreground" Value="Blue" /> </Style> </Window.Resources> Furthermore, adding the default style in the Application.Resources makes it so you can't overwrite that style with another implicit style. <!-- Doesn't work if implicit style with same property is in Application.Resources --> <ComboBox.Resources> <Style TargetType="{x:Type TextBlock}"> <Setter Property="Foreground" Value="Red" /> </Style> </ComboBox.Resources> My questions are: Why is this? Are there other differences between Application.Resources and Windows.Resources ? When should use one over the other? I understand that Application.Resources apply to the entire application, while Window.Resources apply to the window only, however I want to know why the styles in Appli
Tags (comma-separated)
Save Edits
Cancel