question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TextBox/RichEditBox Shouldn't Force Light Theme on Focus

See original GitHub issue

Describe 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

  1. New UWP Application
  2. 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) image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:23 (21 by maintainers)

github_iconTop GitHub Comments

6reactions
lukeblevinscommented, Jun 15, 2019

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.

5reactions
chingucodingcommented, Feb 3, 2020

@chingucoding , would you mind creating some prototype gif where this is done over image?

Sure!

darkthemetextbox

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found