Skip to content

Implement support for high contrast in mica controller sample#1879

Merged
marcelwgn merged 1 commit intomicrosoft:mainfrom
marcelwgn:high-contrast-mica-controller
May 23, 2025
Merged

Implement support for high contrast in mica controller sample#1879
marcelwgn merged 1 commit intomicrosoft:mainfrom
marcelwgn:high-contrast-mica-controller

Conversation

@marcelwgn
Copy link
Copy Markdown
Contributor

Description

We were not properly respecting high contrast in the Mica Controller sample.

Motivation and Context

Fixes #1763

How Has This Been Tested?

Screenshots (if appropriate):

Before: See #1763
After:
Screenshot of the sample window respecting high contrast like the applications behind it.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@marcelwgn marcelwgn enabled auto-merge (squash) May 16, 2025 14:26
@marcelwgn
Copy link
Copy Markdown
Contributor Author

/azp run

@niels9001 niels9001 requested a review from Copilot May 23, 2025 19:09
@marcelwgn marcelwgn merged commit 7eead05 into microsoft:main May 23, 2025
2 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements support for high contrast mode in the Mica Controller sample, addressing issue #1763.

  • Updates the theme configuration by setting the IsHighContrast property based on ThemeSettings derived from the window’s AppWindow ID.
  • Adds necessary using directives for Windows.UI.ViewManagement and Microsoft.UI.System to support the new high contrast API.

Comment on lines +129 to +130
configurationSource = new SystemBackdropConfiguration();
configurationSource.IsHighContrast = ThemeSettings.CreateForWindowId(this.AppWindow.Id).HighContrast;
Copy link

Copilot AI May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic to set 'IsHighContrast' is duplicated between this line and line 207. Consider extracting this operation into a helper method to improve maintainability.

Suggested change
configurationSource = new SystemBackdropConfiguration();
configurationSource.IsHighContrast = ThemeSettings.CreateForWindowId(this.AppWindow.Id).HighContrast;
configurationSource = new SystemBackdropConfiguration();
configurationSource.IsHighContrast = GetIsHighContrast();

Copilot uses AI. Check for mistakes.
Comment on lines +206 to 209
configurationSource.IsHighContrast = ThemeSettings.CreateForWindowId(this.AppWindow.Id).HighContrast;
configurationSource.Theme = (SystemBackdropTheme)((FrameworkElement)Content).ActualTheme;
}

Copy link

Copilot AI May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The repeated setting of 'IsHighContrast' here mirrors the logic at line 130. Extracting a dedicated method for this logic could reduce duplication and ease future updates.

Suggested change
configurationSource.IsHighContrast = ThemeSettings.CreateForWindowId(this.AppWindow.Id).HighContrast;
configurationSource.Theme = (SystemBackdropTheme)((FrameworkElement)Content).ActualTheme;
}
UpdateIsHighContrast();
configurationSource.Theme = (SystemBackdropTheme)((FrameworkElement)Content).ActualTheme;
}
private void UpdateIsHighContrast()
{
if (configurationSource != null)
{
configurationSource.IsHighContrast = ThemeSettings.CreateForWindowId(this.AppWindow.Id).HighContrast;
}
}

Copilot uses AI. Check for mistakes.
@marcelwgn marcelwgn deleted the high-contrast-mica-controller branch May 26, 2025 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Mica] Customizable Mica system backdrop does not respond to High Contrast correctly

3 participants