Reputation: 167
I am developing an app, which offers Rich Text editing capabilities, with light and dark theme. When swithing to the dark theme, I am unable to view the text in focus, and any text coloring gets lost when switching focus. I have created a simple text case that has two rich text boxes, a button to change the selected text to red, and two button to switch between light and dark theme. I am applying a styling to the rich edit box, but it looks like is ignoring the x:Key="TextControlForegroundFocused", or maybe computing SystemBaseHighColor prior applying the theme cahnges.
XAML
<Page.Resources>
<!-- RichEditBox Styling-->
<SolidColorBrush x:Key="TextControlForegroundFocused" Color="{ThemeResource SystemBaseHighColor}"/>
<SolidColorBrush x:Key="TextControlForegroundDisabled" Color="{ThemeResource SystemBaseHighColor}"/>
<SolidColorBrush x:Key="TextControlBackgroundFocused" Color="{ThemeResource TextControlForeground}"/>
</Page.Resources>
<StackPanel Name="_Root" >
<StackPanel Orientation="Horizontal" >
<Button Content="Red" Click="OnRed"/>
<Button Content="Dark Theme" Click="OnDark"/>
<Button Content="Light Theme" Click="OnLight"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<RichEditBox Name="RichEditor1" Style="{ThemeResource EditBoxStyle}" Width="250" Height="200"/>
<RichEditBox Name="RichEditor2" Style="{ThemeResource EditBoxStyle}" Width="250" Height="200"/>
</StackPanel>
</StackPanel>
C#
private void OnRed(object sender, RoutedEventArgs e)
{
RichEditor1.Document.Selection.CharacterFormat.ForegroundColor = Colors.Red;
RichEditor2.Document.Selection.CharacterFormat.ForegroundColor = Colors.Red;
}
private void OnDark(object sender, RoutedEventArgs e)
{
_Root.RequestedTheme = ElementTheme.Dark;
_Root.Background = new SolidColorBrush(Colors.Black);
}
private void OnLight(object sender, RoutedEventArgs e)
{
_Root.RequestedTheme = ElementTheme.Light;
_Root.Background = new SolidColorBrush(Colors.White);
}
Any suggestion on how to make this work?
Upvotes: 0
Views: 232