xamlbackgroundoverlaymaui

.NET MAUI Full scale background image (overlay elements)


Since .NET MAUI is the successor of Xamarin, i am trying to port a Xamarin layout to the new Maui version. The RelativeLayout is removed from Maui. I used the RelativeLayout to position a GUI on top of an image. This image is a full screen background image, stretched in the length, keeping its ratio.

I could create the same layout, but with an full screen image in the background that is 100% height and keeps its ratio. How would I do this in .NET Maui? Its not realy about how to make an image stretch but put layout elements (Like entry, label, etc) on top of an image.


Solution

  • Example using Grid:

    <!-- single cell grid filling its parent. -->
    <Grid>
      <!-- both children default to cell (0,0). Overlaid. -->
      <Image Aspect="AspectFit" ... />
      <!-- nested grid. OR StackLayout, etc. -->
      <Grid ... >
        <!-- GUI content here. -->
      </Grid>
    </Grid>