microsoft / TemplateStudio

Template Studio accelerates the creation of new WinUI 3, WPF, and UWP apps using a wizard-based experience.
Other
2.65k stars 459 forks source link

Setting Dark mode from Settings Page makes the Minimize, Maximize, and Close buttons invisible. #4716

Closed Omenrevlis closed 3 months ago

Omenrevlis commented 7 months ago

Describe the bug

In Navigation Template I added the settings. By default, it implements the ability to switch the app to Dark, Light, or Default. When I change it to Dark the Mininimize, Maximize, and Close buttons are still set to forground black and are invisible unless you hover over them.

I have not modified the toolbar from what the template created. I have not messed with setting any colors of anything. This is how it is after the template studio created it.

To Reproduce

  1. Create a Navigation based Template project
  2. Add a Settings page
  3. Make sure your computer is set to light mode
  4. Run the application
  5. Go to the settings page
  6. Change to Dark Mode (application only)

Additional context

I see where the TitleBarHelper and the ShellPage CS sets the forcolor. Interestingly, if I put a breakpoint in either and run debug to the breakpoint, then just continue running, the title bar foreground is correct.

So something is changing it back to light foreground settings, likely on another thread, but I'm not sure where.

When the main window is deactivated, you can see greyish buttons. But when the windows is active, they are the same color as the title bar (black) and cannot be seen.

Light Mode Not active window Acitve window

Applies to the following platforms:

About your setup

Mysterious-Dev commented 7 months ago

If you use Windows App SDK 1.4, it's fixed with https://github.com/microsoft/TemplateStudio/commit/52d63a4538c676bf97e0486a0df5d44b2cd4841a. We just need to wait @pratikone for a release binary ^^.

Jay-o-Way commented 7 months ago

Looks like https://github.com/microsoft/microsoft-ui-xaml/issues/8899 @Mysterious-Dev where did you find the pr in MS repo that fixed it and for which exact version? I don't see any pr linkt to this ↑ issue.

Jay-o-Way commented 7 months ago

if you to need the custom title bar in 1.4, you can move away from Window.ExtendsContentIntoTitleBar and use the new APIs under Window.AppWindow.TitleBar

https://github.com/microsoft/microsoft-ui-xaml/issues/8899#issuecomment-1742729923

What does the template do?

Mysterious-Dev commented 7 months ago

Looks like https://github.com/microsoft/microsoft-ui-xaml/issues/8899 @Mysterious-Dev where did you find the pr in MS repo that fixed it and for which exact version? I don't see any pr linkt to this ↑ issue.

It's a PR for TemplateStudio. I think he used TemplateStudio 5.4 and updated WindowsAppSDK to 1.4 (with new TitleBar customisation).

Jay-o-Way commented 7 months ago

I know. I asked what your source was. And what method does the template use.

Omenrevlis commented 7 months ago

I am using TemplateStudio 5.4 and WindowsAppSKD 1.4

pratikone commented 7 months ago

New release of Template Studio is here. Do check if it is still happening.

JoySurfer commented 7 months ago

New release of Template Studio is here. Do check if it is still happening.

It seems that these function calls in TitleBarHelper are no longer necessary.

//var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(App.MainWindow); //if (hwnd == GetActiveWindow()) //{ // SendMessage(hwnd, WMACTIVATE, WAINACTIVE, IntPtr.Zero); // SendMessage(hwnd, WMACTIVATE, WAACTIVE, IntPtr.Zero); //} //else //{ // SendMessage(hwnd, WMACTIVATE, WAACTIVE, IntPtr.Zero); // SendMessage(hwnd, WMACTIVATE, WAINACTIVE, IntPtr.Zero); //}

Omenrevlis commented 7 months ago

New release of Template Studio is here. Do check if it is still happening.

I updated to Template Studio 5.5 on the existing solution. There is some improvement but not fully fixed.

If Windows is set to Dark Mode and App is set to default, it works. If Windows is set to Dark Mode and App is set to Dark Mode, it works. If Windows is set to Light Mode and App is set to Dark Mode, it does not work. They are hidden when window is Active. But visible when the window is inactive.

Omenrevlis commented 7 months ago

Starting a new Template Studio project to test and Good news, it works! So a new solution path is fine, but an upgrade to the Extension for Template Studio does not fix it. I can port all my stuff over to a new project. That's fine for me.

I started a template from scratch and when I changed to target .net 8 I had to add these to the project file xml for it to compile.

<ItemGroup>
  <RuntimeHostConfigurationOption Include="System.Runtime.Loader.UseRidGraph" Value="true" />
</ItemGroup>
<PropertyGroup>
  <UseRidGraph>true</UseRidGraph>
</PropertyGroup>
Omenrevlis commented 7 months ago

Well, I'm sorry but there is still some weirdness. Not with the pages themselves, but with ContentDialog. It tires to follow the OS for dark mode.

If OS is light mode, and app is set to default all is great. If OS is dark mode, and app is set to default all is great. if OS is dark mode, and app is dark mode all is great. if OS is dark mode, and app is on light mode, the dialog is in dark mode. If OS is in light mode and app is in dark mode. the dialog is in light mode

image image

Omenrevlis commented 7 months ago

Just for reference, the content of the dialog box is a Page object.

Omenrevlis commented 7 months ago

There is also a measly bug I think no one would care too much about. If the app is set to default and you have a dialog on screen from your app when the OS is changed to a dark or light mode, it only applies to the dialog and not the main window. This fixes itself when you close and restart the app, but it feels odd when it is happening.

pratikone commented 3 months ago

@Omenrevlis no bug is small. Do open an issue for that. Closing this one as it has been fixed.