question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

In WinUI 3, is it possible to create a transparent Xaml Island overlay on top of parent hwnd?

See original GitHub issue

I have created a Xaml Island in a C++ Desktop Application:

    xaml_app_host_ = winrt::Microsoft::UI::Xaml::Application{};
    desktop_window_xaml_source_ = winrt::Microsoft::UI::Xaml::Hosting::DesktopWindowXamlSource{};
    desktop_window_xaml_source_.as<IDesktopWindowXamlSourceNative>()->AttachToWindow(window_);

I see the window created and the child corewindow and bridge window children under my main window:

image

Controls render fine, but the entire window turns black, covering contents rendered to the parent window. I would like the controls in the xaml island to show up overlaid on the contents rendered to the parent window (which is rendering at low latency and controlling the message pump).

This behavior happens even without any controls set to the content.

I have tried futzing with setting ws_ex_layered, and a COLORKEY:

        auto content_bridge = FindWindowEx(window_, NULL, L"Microsoft.UI.Input.DesktopWindowLiftedContentBridge", NULL);
        ::SetWindowLong(content_bridge, GWL_EXSTYLE, GetWindowLong(content_bridge, GWL_EXSTYLE) | WS_EX_LAYERED | WS_EX_TRANSPARENT);
        ::SetLayeredWindowAttributes(content_bridge, RGB(0,0,0), 0, LWA_COLORKEY);

Is this possible? If not, are there any work arounds?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:12
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
smk2007commented, Dec 29, 2020

Hi is there any update on adding transparency to WinUI 3?

0reactions
annmanvelcommented, Sep 18, 2021

Hi,

I am new to UWP and WinUI 3.

I am currently working to make Transparent overlay and click through. Is it possible to achieve these functionalities using UWP(C#) or WinUI 3 in UWP (C#); without using win32 api dlls?

I have achieved transparency and click through with win32 api’s. But I need to know the possibilities other than win32 api’s .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Need help to make window as overlay in WinUI3 ...
I have created WinUI3 project to make a overlay application show it on top of every other application. I need below things to...
Read more >
Host WinRT XAML controls in desktop apps (XAML Islands)
Starting in Windows 10, version 1903, you can host WinRT XAML controls in non-UWP desktop applications using a feature called XAML Islands.
Read more >
Maui -- How to make the background color transparent?
In WinUI 3, is it possible to create a transparent Xaml Island overlay on top of parent hwnd? #2956 · Share.
Read more >
A deep-dive into WinUI 3 in desktop apps - Windows Blog
A deep-dive into WinUI 3 in desktop apps ... XAML Islands was our first solution to enable developers to use UWP XAML inside...
Read more >
Untitled
Wpf transparent overlay window WPF Window with transparent background ... In WinUI 3, is it possible to create a transparent Xaml Island overlay...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found