-
Notifications
You must be signed in to change notification settings - Fork 689
Description
Issue type
enhancement
Which version of the app?
WinUI 3 Gallery
Description
Add this line or something similar:
Mica will apply an opaque background which will show the desktop image
Acrylic will simulate true transparency and apply an opaque background that shows what's behind the window.
A Window can have one of these 5 backgrounds:
- Solid
- Mica
- Mica Alt
- Acrylic Base
- Acrylic Thin
Use this example:
`// Mica/Acrylic
WindowsSystemDispatcherQueueHelper m_wsdqHelper; // See separate sample below for implementation
Microsoft.UI.Composition.SystemBackdrops.MicaController m_micaController;
Microsoft.UI.Composition.SystemBackdrops.SystemBackdropConfiguration m_configurationSource;
Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicController m_acrylicController;
public bool TrySetBackdrop(int backdropType)
{
// Clean up previous controllers if any
m_micaController?.Dispose();
m_micaController = null;
m_acrylicController?.Dispose();
m_acrylicController = null;
if (backdropType == 0)
return true; // No background requested
m_wsdqHelper ??= new WindowsSystemDispatcherQueueHelper();
m_wsdqHelper.EnsureWindowsSystemDispatcherQueueController();
m_configurationSource ??= new Microsoft.UI.Composition.SystemBackdrops.SystemBackdropConfiguration();
this.Activated += Window_Activated;
this.Closed += Window_Closed;
((FrameworkElement)this.Content).ActualThemeChanged += Window_ThemeChanged;
m_configurationSource.IsInputActive = true;
SetConfigurationSourceTheme();
var target = this.As<Microsoft.UI.Composition.ICompositionSupportsSystemBackdrop>();
switch (backdropType)
{
case 1: // Mica Base
if (!Microsoft.UI.Composition.SystemBackdrops.MicaController.IsSupported())
return false;
m_micaController = new Microsoft.UI.Composition.SystemBackdrops.MicaController
{
Kind = Microsoft.UI.Composition.SystemBackdrops.MicaKind.Base
};
m_micaController.AddSystemBackdropTarget(target);
m_micaController.SetSystemBackdropConfiguration(m_configurationSource);
break;
case 2: // Mica BaseAlt
if (!Microsoft.UI.Composition.SystemBackdrops.MicaController.IsSupported())
return false;
m_micaController = new Microsoft.UI.Composition.SystemBackdrops.MicaController
{
Kind = Microsoft.UI.Composition.SystemBackdrops.MicaKind.BaseAlt
};
m_micaController.AddSystemBackdropTarget(target);
m_micaController.SetSystemBackdropConfiguration(m_configurationSource);
break;
case 3: // Acrylic Base
if (!Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicController.IsSupported())
return false;
m_acrylicController = new Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicController
{
Kind = Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicKind.Base
};
m_acrylicController.AddSystemBackdropTarget(target);
m_acrylicController.SetSystemBackdropConfiguration(m_configurationSource);
break;
case 4: // Acrylic Thin
if (!Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicController.IsSupported())
return false;
m_acrylicController = new Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicController
{
Kind = Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicKind.Thin
};
m_acrylicController.AddSystemBackdropTarget(target);
m_acrylicController.SetSystemBackdropConfiguration(m_configurationSource);
break;
default:
return false; // Unknown type
}
return true;
}
`
Screenshots
No response
Windows version
No response
Additional context
The current examples are not clear enough