Reputation: 1505
Is it possible to globally set Foreground for Border for internal controls? Similar to WPF TextBlock.Foreground
attached property. I tried this code, it doesn't work:
<Border.Resources>
<SolidColorBrush
x:Key="SystemControlForegroundAltMediumHighBrush"
Color="Black"
/>
<SolidColorBrush
x:Key="SystemControlForegroundAltHighBrush"
Color="Black"
/>
<SolidColorBrush
x:Key="SystemControlForegroundBaseMediumBrush"
Color="Black"
/>
<SolidColorBrush
x:Key="SystemControlForegroundBaseHighBrush"
Color="Black"
/>
<SolidColorBrush
x:Key="SystemControlForegroundBaseLowBrush"
Color="Black"
/>
<SolidColorBrush
x:Key="SystemControlForegroundBaseMediumHighBrush"
Color="Black"
/>
<SolidColorBrush
x:Key="SystemControlForegroundBaseMediumLowBrush"
Color="Black"
/>
</Border.Resources>
I also tried DefaultTextForegroundThemeBrush
and SystemColorWindowTextColor
P.S. I'll explain the reasons a little - I'm writing a utility to translate WPF xaml code into the equivalent UWP / WinUI, and I'm looking for an alternative without redefining styles (because internal controls can explicitly set their own). So far, the only solution I see is to explicitly set the Foreground property on all TextBlocks inside the Border if it's not set.
Upvotes: 0
Views: 401
Reputation: 8681
Is it possible to globally set Foreground for Border for internal controls?
I have to say the answer is No. There is no way to globally change the system color just applies to a Border and its children. You could only override the system color in the Application.Resources
from the App.Xaml. And this will affect all the controls in the app that uses this color.
For your scenario, I'd suggest you change the Foreground
property of these child controls in the Border control.
Like this:
<Border>
<Border.Resources>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="Red" />
</Style>
</Border.Resources>
<!--red text-->
<TextBlock Text="2132123314132133143123314213412343" />
</Border>
<!--black text-->
<TextBlock Text="2132123314132133143123314213412343" />
Upvotes: 0