Search code examples
.net-mauiglobal-object

Is it possible to create global objects in .NET MAUI


When I saw the TabBar and the Flyout menu in .NET Maui I started wondering if its possible to create your own global object for your application. does anyone know how to do this?

(I want to add a status icon at the corner of my screen without having to manually add it to all pages.)


Solution

  • You can create a simple Floating Button and add it to your pages. You can create an image with a transparent background in your favorite editor and then assign it a location on the Page.

    You can refer to the following code:

      <AbsoluteLayout>
         <!--Other components-->
         <ImageButton Source="icon.png" 
                BackgroundColor="Green"
            CornerRadius="80"
                AbsoluteLayout.LayoutFlags="PositionProportional"  
                AbsoluteLayout.LayoutBounds=".95,.95,80,80" />
    </AbsoluteLayout>