Skip to content

Overlaying a StackLayout on another StackLayout does not block interaction Β #10252

Open

Description

@alfarajali

Description

I overlayed two Stack Layouts on top of each other using AbsoluteLayout and I was still able to interact with the button in the StackLayout . Is this expected because to my knowledge the second StackLayout should block interaction with the main StackLayout.

Steps to Reproduce

  1. Create a .net MAUI app
  2. Copy below code to the XAML file:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiApp2.MainPage">

    <AbsoluteLayout>

        <StackLayout AbsoluteLayout.LayoutFlags="All"
                     AbsoluteLayout.LayoutBounds="0,0,1,1"
                     Margin="5">

            <Button Text="Clic Me!" BackgroundColor="GreenYellow" Clicked="Button_Clicked"/>
        </StackLayout>

        <StackLayout AbsoluteLayout.LayoutFlags="All"
                     AbsoluteLayout.LayoutBounds="0,0,1,1"
                     BackgroundColor="Gray"
                     Opacity="0.6">
            
        </StackLayout>
        
    </AbsoluteLayout>
    
</ContentPage>
  1. Copy below code in the code behind file:
namespace MauiApp2;

public partial class MainPage : ContentPage
{
	public MainPage()
	{
		InitializeComponent();
	}

	private void Button_Clicked(object sender, EventArgs e)
	{
		DisplayAlert("", "Hello World", "Cancel");
	}
}
  1. Run the app
  2. Click the button (which is placed in the first StackLayout) and it will fire the alert; the second StackLayout should block interaction with the first one.

Link to public reproduction project repository

No link

Version with bug

Unknown/Other (please specify)

Last version that worked well

Unknown/Other

Affected platforms

Android, I was not able test on other platforms

Affected platform versions

Android 9

Did you find any workaround?

No response

Relevant log output

No response

Activity

  1. added
    t/bug
    on Sep 22, 2022
  2. changed the title [-]Overlaying a StackLayout another StackLayout does not block interaction [/-] [+]Overlaying a StackLayout on another StackLayout does not block interaction [/+] on Sep 22, 2022
  3. added
    area-layout
    on Sep 22, 2022
  4. added this to the Backlog milestone on Sep 22, 2022
  5. alfarajali commented on Sep 23, 2022

    @alfarajali
    Author

    Is there any workaround to address this requirement?

  6. eynerdevp commented on Jan 4, 2023

    @eynerdevp

    still not working

  7. self-assigned this
    on Mar 4, 2023
  8. moved this from Todo to In Progress in MAUI SDK Ongoingon Mar 4, 2023
  9. added a commit that references this issue on Mar 6, 2023
    8500e7e
  10. mattleibow commented on May 1, 2023

    @mattleibow
    Member

    There was a workaround found in #9153 (comment)

    Simplest workaround for me was adding an empty TapGestureRecognizer to the view that's over top.

  11. 25 remaining items

  12. MarMarIV commented on Jul 3, 2024

    @MarMarIV

    Same problem occured on iOS platform, on version 8.0.61

    Is there any progress? Or workaround?

  13. riccardominato commented on Jul 3, 2024

    @riccardominato
  14. yaseenCh commented on Jul 15, 2024

    @yaseenCh

    i have an issue in maui when i load data during this period when i click on my screen my app is crashing. if i dont touch the screen then its work fine . i have do every things like is enabled event fields dusring data loading but during loading click not click but after that it trigring all clicks and app will be crash. i have also async all function but still when i attach data its stucked for some time

  15. holecekp commented on Dec 17, 2024

    @holecekp

    The problem is still in the latest .NET MAUI 9 version on Android (in Border and Grid in my case). However, at least the workaround with adding a TapGestureRecognizer works.

  16. cagriy commented on Jan 11, 2025

    @cagriy

    Hi @PureWeen , is it possible to move this one to NET9 Servicing? It was on NET 8 Servicing, but that one is closed now as far as I can see.

  17. janseris commented on Mar 23, 2025

    @janseris

    The problem is still in the latest .NET MAUI 9 version on Android (in Border and Grid in my case). However, at least the workaround with adding a TapGestureRecognizer works.

    This will only block touch interaction. You can stil activate controls using Tab and Enter keys on keyboard.

  18. removed their assignment
    on Jul 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-layoutp/2partnerpartner/cat 😻platform/androidt/bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions