Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Setting ModalPage background to transparent no longer displays the underlying view #7450

Open
PureWeen opened this issue May 24, 2022 · 7 comments
Labels
area-controls-modal platform/windows 🪟 s/triaged Issue has been reviewed t/bug Something isn't working
Milestone

Comments

@PureWeen
Copy link
Member

PureWeen commented May 24, 2022

This behavior broke
xamarin/Xamarin.Forms#8551

The reason here is that the modal page is now nested inside a NavigationView so we need to set some backgrounds on the WindowRootView to transparent so the underlying view can shine through

Work started here
https://github.com/dotnet/maui/tree/fix_winui_modal_transparent

@ghost
Copy link

ghost commented Sep 6, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@eddie010
Copy link

Can confirm this bug. Workaround is to set the background of the parent object of the page to transparent.

var parentView = (Page)this.Parent;
parentView.BackgroundColor = Colors.Transparent;

@PureWeen PureWeen changed the title Setting ModalPage background to transparent no longer displays the underlying view [Windows] Setting ModalPage background to transparent no longer displays the underlying view Jan 26, 2023
dabbinavo added a commit to dabbinavo/repro_winui-contentpage-not-transparent that referenced this issue Jan 27, 2023
as suggested by @addie010 in dotnet/maui#7450
@dabbinavo
Copy link

@eddie010 I am really interested in your workaround, but can't get it working.

Here are the things i tried, but depending on where i put your workaround, i get different exceptions:
See dabbinavo/repro_winui-contentpage-not-transparent@db85060

Which page is this?

  • The page that is partly transparent
  • Application.Current.MainPage
  • The page that performs the PushModalAsync?

And when/where do you apply the code?

  • After the call of PushModalAsync
  • ...

@JohnHunterACS
Copy link

@dabbinavo Did you get a response from @eddie010 about how to apply the workaround?

@dabbinavo
Copy link

@JohnHunterACS Unfortunately not. Still waiting for someone who knows how to apply the workaround..

dabbinavo added a commit to dabbinavo/repro_winui-contentpage-not-transparent that referenced this issue Feb 27, 2023
@dabbinavo
Copy link

dabbinavo commented Feb 27, 2023

@PureWeen Is there any workaround that can be applied without touching the MAUI library?

I tried setting the Background of the WindowRootView to Transparent as mentioned by you in the issue description:

// This is a member function of the transparent modal ContentPage and is called on the modal ContentPage instance after it is pushed  via Navigation.PushModalAsync
public void ApplyWorkaroundPureWeen()
{
	var windowManager = this.Handler.MauiContext.Services.GetRequiredService<NavigationRootManager>();
	var windowRootView = windowManager.RootView as WindowRootView;
	windowRootView.Background = SolidColorBrush.Transparent.Color.ToPlatform(); // Still a white background. Even if using e.g. 'Blue' instead of 'Transparent'
}

You can see the full demo application including this workaround approach here:
dabbinavo/repro_winui-contentpage-not-transparent@c0b913c

Unfortunately, the underlying view does not shine through and the part below the transparent area of the modal ContentPage is still white. It is even white, when setting the background of the WindowRootView to something like blue.

I also tried the workaround provided by @eddie010, but unfortunately don't get it running.

@samhouts samhouts added the t/bug Something isn't working label Jul 31, 2023
@Dokug
Copy link

Dokug commented Oct 16, 2023

I think this has been fixed with the latest .NET 8 RC, at least for me.
If someone could confirm this, this issue could maybe be closed?

@Zhanglirong-Winnie Zhanglirong-Winnie added the s/triaged Issue has been reviewed label Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-modal platform/windows 🪟 s/triaged Issue has been reviewed t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants