GeoSaffer
GeoSaffer

Reputation: 163

BoxView background gradient not working in .Net Maui

In .Net Maui I creates a new Page and inserted a BoxView, I added a Background Gradient with 2 GradientStops.

Tested it on Android and iOS and it does not seem to work.

<Grid  HeightRequest="200" WidthRequest="200"  >
  <Grid.Background>
    <LinearGradientBrush EndPoint="0,1">
      <GradientStop Color="Red"
                    Offset="0.1" />
      <GradientStop Color="Green"
                    Offset="0.8" />
    </LinearGradientBrush>
  </Grid.Background>
</Grid>

<BoxView  HeightRequest="200" WidthRequest="200" >
  <BoxView.Background>
    <LinearGradientBrush EndPoint="0,1">
      <GradientStop Color="Red"
                    Offset="0.1" />
      <GradientStop Color="Green"
                    Offset="0.8" />
    </LinearGradientBrush>
  </BoxView.Background>
</BoxView>

enter image description here

Upvotes: 1

Views: 1020

Answers (1)

GeoSaffer
GeoSaffer

Reputation: 163

To fix this issue set the Color to Transparent and you will see the background gradient

<BoxView  HeightRequest="200" WidthRequest="200" Color="Transparent" >
  <BoxView.Background>
    <LinearGradientBrush EndPoint="0,1">
      <GradientStop Color="Red"
                    Offset="0.1" />
      <GradientStop Color="Green"
                    Offset="0.8" />
    </LinearGradientBrush>
  </BoxView.Background>
</BoxView>

Upvotes: 1

Related Questions