loadingmaui

Disable user interaction while activity indicator is running .net MAUI


I want to disable user interaction with the page while activity indicator is running for my app which I'm building in .net MAUI. I tried creating a transparent , full screen view to overlap with the page and set its visibility to true when activity indicator isRunning is set to true but still I can interact with the page. Any suggestions on how to do this properly.

See below sample code to mimic the issue.

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns:local="clr-namespace:HomeMade.Extensions"
           xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:avatarview="clr-namespace:Syncfusion.Maui.Core;assembly=Syncfusion.Maui.Core"
             x:Class="HomeMade.Pages.ShopListPage"
             FlowDirection="RightToLeft"
             NavigationPage.HasNavigationBar="False"
             BackgroundColor="GhostWhite"
             x:Name="Page"
             >

<ContentPage.Content>
        <StackLayout>
            
      
    <local:NavigationControl  PageTitle="المتاجر"/>
            
        <AbsoluteLayout VerticalOptions="FillAndExpand">


            
            <StackLayout 
                         AbsoluteLayout.LayoutBounds="0.0,0.0,1.0,1.0"
                         AbsoluteLayout.LayoutFlags="All">
                
                <!--- content -->

  </StackLayout>
                <BoxView x:Name="bxView"
                    AbsoluteLayout.LayoutFlags="All" 
             AbsoluteLayout.LayoutBounds="0,0,1,1" 
             BackgroundColor="Transparent"

             
                         />
                <ActivityIndicator  x:Name="activity"
                                AbsoluteLayout.LayoutBounds="0.5,0.5,0.1,0.1"
                               AbsoluteLayout.LayoutFlags="All"    
                             
                              Color="Blue">
            </ActivityIndicator>
            
        </AbsoluteLayout>

        </StackLayout>
    </ContentPage.Content>
    
</ContentPage>

I'm setting the activity indicator and box view visibility in the code behind as below where i'm using task delay to test the functionality.

    bxView.IsVisible = true; 
    activity.IsRunning = true;
    
    await Task.Delay(10000);

    bxView.IsVisible = false;
    activity.IsRunning = false;

Solution

  • The issue was reported as a bug, you can follow the status from this link https://github.com/dotnet/maui/issues/10252