Skip to content

Commit

Permalink
Manually set the colors of the TabViewBackground (#12460)
Browse files Browse the repository at this point in the history
This has been a saga.

Basically, any resources in `App.xaml` aren't going to be able to reference other theme-aware resources. We can't change the theme of the app at runtime, only elements within the app. So we can't use `ApplicationPageBackgroundThemeBrush` in app.xaml, because it will ALWAYS be evaluated as the OS theme version of that brush.

* regressed in #12326
* See also #10864
* #3917 CANNOT be fixed in the same way. We're lucky here that the TabView uses a `{ThemeResource TabViewBackground}` in markup to set the bg. We're not similarly lucky with the Pane one. 
* [x] closes #12356
* [x] Tested manually. You can confirm, my eyes are bleeding from the OS-wide light mode
  • Loading branch information
zadjii-msft committed Mar 3, 2022
1 parent 9e978b5 commit abdfbd5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
22 changes: 18 additions & 4 deletions src/cascadia/TerminalApp/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,31 @@
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Dark">
<!-- Define resources for Dark mode here -->
<StaticResource x:Key="TabViewBackground"
ResourceKey="ApplicationPageBackgroundThemeBrush" />

<!--
This is the color of
ApplicationPageBackgroundThemeBrush, which is
evaluated as SolidBackgroundFillColorBase. If we try
to use those resources directly though, we don't get
the properly themed versions. Presumably because the
App itself can't have it's RequestedTheme changed at
runtime.
See GH #12356 for more history on the subject.
-->
<SolidColorBrush x:Key="TabViewBackground"
Color="#202020" />

<StaticResource x:Key="UnfocusedBorderBrush"
ResourceKey="ApplicationPageBackgroundThemeBrush" />


</ResourceDictionary>

<ResourceDictionary x:Key="Light">
<!-- Define resources for Light mode here -->
<StaticResource x:Key="TabViewBackground"
ResourceKey="ApplicationPageBackgroundThemeBrush" />
<SolidColorBrush x:Key="TabViewBackground"
Color="#F3F3F3" />

<StaticResource x:Key="UnfocusedBorderBrush"
ResourceKey="ApplicationPageBackgroundThemeBrush" />
Expand Down
1 change: 0 additions & 1 deletion src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ namespace winrt::TerminalApp::implementation
if (_settings.GlobalSettings().UseAcrylicInTabRow())
{
const auto res = Application::Current().Resources();

const auto lightKey = winrt::box_value(L"Light");
const auto darkKey = winrt::box_value(L"Dark");
const auto tabViewBackgroundKey = winrt::box_value(L"TabViewBackground");
Expand Down

0 comments on commit abdfbd5

Please sign in to comment.