Working with Mica
See original GitHub issueI know Mica is not supported yet. However, with the help of some PInvoke functions, Mica is activated on WPF apps
so I tried to do the same in WinUI3 preview 3
[DllImport("dwmapi.dll")]
public static extern int DwmSetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwAttribute, ref int pvAttribute, int cbAttribute);
[Flags]
public enum DwmWindowAttribute : uint
{
DWMWA_USE_IMMERSIVE_DARK_MODE = 20,
DWMWA_MICA_EFFECT = 1029
}
public static void EnableMica(IntPtr source, bool darkThemeEnabled)
{
int trueValue = 0x01;
int falseValue = 0x00;
// Set dark mode before applying the material, otherwise you'll get an ugly flash when displaying the window.
if (darkThemeEnabled)
DwmSetWindowAttribute(source, DwmWindowAttribute.DWMWA_USE_IMMERSIVE_DARK_MODE, ref trueValue, Marshal.SizeOf(typeof(int)));
else
DwmSetWindowAttribute(source, DwmWindowAttribute.DWMWA_USE_IMMERSIVE_DARK_MODE, ref falseValue, Marshal.SizeOf(typeof(int)));
DwmSetWindowAttribute(source, DwmWindowAttribute.DWMWA_MICA_EFFECT, ref trueValue, Marshal.SizeOf(typeof(int)));
}
public MainWindow()
{
this.InitializeComponent();
IntPtr hwnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
EnableMica(hwnd, true);
}
TitleBar activates Mica well, but not Windows content
Is there a solution?😁
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (5 by maintainers)
Top Results From Across the Web
Mica Quickstart Guide: 61 Uses for Mica Powder
The guide features 61 of the best projects and uses for mica powder ... Safety First - Wear a mask and gloves when...
Read more >How to use Mica Powder - The Bench
Create moonstone effects by taking small amounts of the powder and mixing it into epoxy resin. This design works particularly well with a...
Read more >What Is Mica Powder and 23 Ways to Use It
Mica powder works best when used with melt-and-pour soap bases, in my personal experience. You simply pour some of the powder into the...
Read more >The Ultimate Guide on How to Use Mica Powder
If you're working with paper, it's as simple as adding the powder to water and brushing or spraying it on! You can mix...
Read more >7 Ways To Use Mica Powder in Craft Projects
Mica powder is an excellent colorant for various projects, including polymer clay. The stickiness of the clay means you can work the mica...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You need to set the background of your application to transparent.
You can do this via Win32 API calls. I have created a sample project here: https://github.com/IcySnex/WinUI3-Transparent-Mica-Acrylic-Blurred. You can also look at a video here: https://www.youtube.com/watch?v=mfS8PT9Z3u8. But be aware that you need to have at least the WindowsAppSDK version 1.1 - preview 1.
That method depends on a private API that has been removed since 22494+ (in 22523 and later it’s replaced. The proper way is to use
Windows.UI.Composition.Compositor
, however this approach requires either a swapchain or aHwndHost
(or some other way idk), the latter causes the airspace problem.