TextBox/RichEditBox Shouldn't Force Light Theme on Focus
See original GitHub issueDescribe the bug
Both TextBox
and RichEditText
include a visual state like this:
<VisualState x:Name="Focused">
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement" Storyboard.TargetProperty="RequestedTheme">
<DiscreteObjectKeyFrame KeyTime="0" Value="Light" />
</ObjectAnimationUsingKeyFrames>
</VisualState>
This interferes with lightweight styling, most notably when trying to theme the editor to remain dark in a dark theme.
Steps to reproduce the bug
- New UWP Application
- Use this XAML for the main page (modify the
x:Class
to match your project)
<Page x:Class="App6.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
RequestedTheme="Dark">
<Grid>
<Grid.Resources>
<SolidColorBrush x:Key="TextControlBackground" Color="Transparent" />
<SolidColorBrush x:Key="TextControlBackgroundPointerOver" Color="Transparent" />
<SolidColorBrush x:Key="TextControlBackgroundFocused" Color="{ThemeResource SystemAltHighColor}" />
<SolidColorBrush x:Key="TextControlForegoundFocused" Color="{ThemeResource SystemBaseHighColor}" />
</Grid.Resources>
<TextBox Text="Here is some text that I want to edit in a dark editor" FontSize="30"
TextWrapping="Wrap" />
</Grid>
</Page>
Expected behavior
I expect the TextBox to use SystemBaseHighColor
from the dark theme, but it resolves to the Light theme instead. Even worse, TextControlBackgroundFocused
resolves to dark because its theme isn’t changed in the Style
.
Screenshots
Screenshot showing the dark text (with some text selected in order to show that text exists)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:8
- Comments:23 (21 by maintainers)
Top Results From Across the Web
UWP RichEditBox text color issue when saved in dark ...
UWP RichEditBox text color issue when saved in dark mode and opened in light mode · Make sure your device theme is on...
Read more >User experience guidelines for Universal Windows Platform ...
A set of styles that automatically gives your app a light or dark theme (your choice) and can incorporate the user's accent color...
Read more >Chapter 1- Why WPF, and What About Silverlight
2D is the primary focus of WPF; its 3D support is focused on data ... and improved Indic script support), and enhancements to...
Read more >Vim documentation: options
When included, they force Vim to always break either symbolic or hard links by doing exactly what the "no" option does, renaming the...
Read more >Uno.UI - Performance
Force the size of images anywhere possible. When binding the Visibility property, make sure to always set TargetNullValue and FallbackValue to collapsed ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think by default, user input controls like TextBox should not force light theme when dark mode is enabled. In many apps, it looks jarring and quite inconsistent for this control to light up white when focus is invoked.
Sure!