dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.03k stars 1.73k forks source link

Setting InputTransparent=true on a layout will remove the background #17389

Open mattleibow opened 1 year ago

mattleibow commented 1 year ago

Description

I would expect this to appear as a Green box with a button, instead it is a red box with a button - the green background is gone.

    <Grid x:Name="rootLayout" InputTransparent="False" Background="Red">
        <Grid x:Name="nestedLayout" InputTransparent="True" Background="Green">
            <Button x:Name="testButton" Text="Test Button" Clicked="ClickSuccess" HorizontalOptions="Center" VerticalOptions="Center" InputTransparent="False" />
        </Grid>
    </Grid>

To get the background that is input transparent, we add a canvas to the layout - except that we can remove this at any time. The LayoutHandler for Windows just adds and removes children based on index, yet the background is at index 0.

Steps to Reproduce

  1. File | New | Maui App
  2. Copy the XAML
  3. Run
  4. Observe the red background

Link to public reproduction project repository

N/A

Version with bug

8.0.0-rc.1.9171

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

ghost commented 1 year ago

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

mattleibow commented 1 year ago

Right now, the Layout is handing this case of a background, but probably for layouts we should use a wrapper view and put the background in there instead. This makes the layout handler code far simpler. The wrapper view can be the part that adds a canvas and manages that.

XamlTest commented 9 months ago

Verified this on Visual Studio Enterprise 17.9.0 Preview 1(8.0.3). Repro on Windows 11, not repro on Android 14.0-API34, iOS 17.0 and MacCatalyst with below Project: 17389.zip

image