Skip to content

[Enhancement idea] Add ability for developers to override Foreground, FontSize at root of XAML #14

@giovanni-a

Description

@giovanni-a

Currently, if the user sets Foreground at the root of the XAML:

`

<Grid Background="{DynamicResource Theme_BackgroundBrush}">
    <TextBlock Text="Hello, World!" FontSize="23" Margin="32,32,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
    <Button Content="Button" Margin="32,80,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="88" Height="32" />
    <RadioButton Content="RadioButton" Margin="32,128,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" Height="32" />
    <CheckBox Content="Checkbox" Margin="32,176,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" Height="32" />
</Grid>

`

it won't affect the text color of Button, RadioButton, CheckBox etc:

Image

This is due to the fact that, in the modern theme, we set Foreground, FontSize, etc. in a style, like this:
<Setter Property="Foreground" Value="{DynamicResource Theme_TextBrush}" />
and the style takes precendence on inherited values.

To solve this problem, I propose that we remove such style setters and, instead, we implement a system that, when a theme is applied, automatically sets Foreground, FontSize, etc. to the RootVisual, so that the property is inherited to the full visual tree, and developers can easily override those properties on a subtree.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions