maui icon indicating copy to clipboard operation
maui copied to clipboard

Frame.Background LinearGradientBrush not working on maccatalyst

Open edgedj opened this issue 2 years ago • 2 comments

Description

On windows, the following XAML creates a rounded corner frame with a linear gradient in windows; however, on maccatalyst the gradient does not appear and the frame stays white:

 <Frame BorderColor="Black" CornerRadius="20" HasShadow="False" Padding="8"  >
                <Frame.Background>
                    <LinearGradientBrush EndPoint="1,0">
                        <GradientStop Color="#B92748" Offset="0.1" />
                        <GradientStop Color="#DB3EB1" Offset="1.0" />
                    </LinearGradientBrush>
                </Frame.Background>
                     <VerticalStackLayout 
                        Spacing="25" 
                        Padding="30,0" 
                        VerticalOptions="Center">

                        <Image
                            Source="dotnet_bot.png"
                            SemanticProperties.Description="Cute dot net bot waving hi to you!"
                            HeightRequest="200"
                            HorizontalOptions="Center" />
                
                        <Label 
                            Text="Hello, World!"
                            SemanticProperties.HeadingLevel="Level1"
                            FontSize="32"
                            HorizontalOptions="Center" />
            
                        <Label 
                            Text="Welcome to .NET Multi-platform App UI"
                            SemanticProperties.HeadingLevel="Level2"
                            SemanticProperties.Description="Welcome to dot net Multi platform App U I"
                            FontSize="18"
                            HorizontalOptions="Center" />

                        <Button 
                            x:Name="CounterBtn"
                            Text="Click me"
                            SemanticProperties.Hint="Counts the number of times you click"
                            Clicked="OnCounterClicked"
                            HorizontalOptions="Center" />

                    </VerticalStackLayout>
            </Frame>

Screenshot 2022-06-16 at 13 13 22

Steps to Reproduce

surround the vanilla 'dotnet new maui' waving bot with a Frame as above

Version with bug

6.0.400 (current)

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

MacOS 15.4

Did you find any workaround?

not a workaround but changing the BorderColor while the app is running and after a hot reload the gradient background appears but after a restart of the application the gradient reverts to white

Relevant log output

No response

edgedj avatar Jun 16 '22 12:06 edgedj

verified repro on Mac with above project.

kristinx0211 avatar Jun 17 '22 04:06 kristinx0211

As a workaround, you can replace Frame with ContentView to see if it also works for you: Example code:

<ContentView
                HeightRequest="120"
                HorizontalOptions="FillAndExpand"
                Margin="-2"
                Padding="20, 45, 20, 0">
            <ContentView.Background>
                <LinearGradientBrush>
                    <GradientStop Color="#00A7B5" Offset="0.1" />
                    <GradientStop Color="#721474" Offset="1.0" />
                </LinearGradientBrush>
            </ContentView.Background>
</ContentView>

If you need border, border radius and shadow, you can combine ContentView with Border and Shadow MAUI elements.

hermben avatar Sep 19 '22 20:09 hermben