Closed sylveon closed 1 year ago
@jevansaks Is this expected?
@marb2000 FYI
@jevansaks Is this expected?
Yes, but we should use this issue to track making it work. The problem is that currently we only know how to get the current Window -- there's no way to get the DesktopWindowXamlSource from an element. We'll need an API for apps that want to do this to tell us what the DesktopWindowXamlSource is to set the mica brush in the right place.
Is that not what XamlRoot is for?
In any case, the DesktopWindowXamlSource
is abstracted away from the XAML I host in Islands, so I'd love to not have to break that abstraction on my side.
You can have mica material support in Windows 11 and Windows 10 using DWM Private API, The DWM Api has a private function called DwmpCreateSharedThumbnailVisual
. This method can be used to acquire the live bitmap of any window into an IDCompositionVisual
. use this function to capture the desktop hwnd (Progman). Once you get the Visual you can clip the Visual with window RECT
using the Rectangle Clip or use Atlas Effect from Windows.UI.Composition and then using IDCompositionBlendEffect
and IDCompositionGaussianBlurEffect
can give you the Mica Effect. Since this issue is about XAML Islands. you need to convert IDCompositionVisual
to Windows.UI.Composition.Visual
and apply all effects., you can do it through Interop Compositor.
A sample demo of this is available Here. Change This line in the sample from
compositor->SetAcrylicEffect(hwnd, AcrylicCompositor::BACKDROP_SOURCE_HOSTBACKDROP, param);
To
compositor->SetAcrylicEffect(hwnd, AcrylicCompositor::BACKDROP_SOURCE_DESKTOP, param);
This will use the desktop Live bitmap as backdrop. Change the Tint Opacity and blur amount for desired effect. This might even be possible in windows 8 and above, because windows 8 and above also has these functions in dwmapi.dll.
I highly does not recommend using DWM private functions, since it can be changed or removed any time, but having something is better than having nothing😁
Or we could just use acrylic on Windows 10 and manually use the Mica composition API on 11, until WinUI 2 ships a fix.
Or we could just use acrylic on Windows 10 and manually use the Mica composition API on 11, until WinUI 2 ships a fix.
Ya its the better option than trusting private Api
I added some code implementing mica as a composition brush in the linked app window related issue.
Unfortunately, this code does not help because I use C++
This app which forces all win32 apps to get "mica effect" titlebar and even backdrop. Hopefully this can help. https://github.com/MicaForEveryone/MicaForEveryone/
No, it does not help, as composition attributes are ignored by XAML islands.
Any update on this? @StephenLPeters @jevansaks
It's been well over a year and I still cannot use Mica.
Bump, still an issue
Just wanted to add context for closure - this is in WinUI2-specific Mica implementation, and unfortunately we are unable to investigate most WinUI2-only issues due to the current focus on WinUI3 (more on the policy here). If this is a blocker, please consider migration to WinAppSDK where MicaBackdrop provides fully-featured support for this material.
Describe the bug Mica material either renders as fully transparent or just plain white in XAML islands.
Steps to reproduce the bug
Steps to reproduce the behavior:
muxc:BackdropMaterial.ApplyToRootOrPageBackground="True"
to a pageExpected behavior I expected to see the Mica brush.
Screenshots
Version Info
NuGet package version:
[Microsoft.UI.Xaml 2.6.0]
Additional context I don't have a repro project due to the complexity of getting XAML Islands and WinUI set up together.