Can I create a border with a gradient background?

Platform: .NET MAUI| Category: General

Yes, you can create a border with a gradient background using a LinearGradientBrush or RadialGradientBrush as the background. Here’s an example for using a LinearGradientBrush:
XAML:

<Border Padding="10" WidthRequest="100" HeightRequest="100">
        <Border.Background>
            <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                <GradientStop Color="Red" Offset="0.0"/>
                <GradientStop Color="Blue" Offset="1.0"/>
            </LinearGradientBrush>
        </Border.Background>
</Border>

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.