Grid Row's Background Color

jrahma 116 Reputation points
2021-02-25T18:39:26.663+00:00

Hi,

How can I change the background color of a Grid's Row? I know I can put a BoxView or anything else but my target is to have a transparent color. However, in the below example, the row is always with the white background color.

<Grid Grid.Row="1" BackgroundColor="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <SyncfusionBorder:SfBorder Grid.Row="1" Margin="10" BorderColor="Black" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" CornerRadius="25">
        <Label Grid.Row="2" Text="Source : www.u.ae" Padding="20" BackgroundColor="Black" TextColor="White" HorizontalOptions="FillAndExpand" HorizontalTextAlignment="Start" VerticalOptions="FillAndExpand" VerticalTextAlignment="Center" FontSize="Medium" />
    </SyncfusionBorder:SfBorder>
</Grid>
Developer technologies .NET Xamarin
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JessieZhang-MSFT 7,716 Reputation points Microsoft External Staff
    2021-02-26T02:30:31.357+00:00

    Hello,

    Welcome to our Microsoft Q&A platform!

    Are you talking about Syncfusion SFBorder? If yes, I did a test based on the sample at the bottom of the page(Getting Started with Xamarin Border (SfBorder)) and added the following code in MainPage.xaml:

    <?xml version="1.0" encoding="utf-8" ?>  
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"  
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"  
                 xmlns:local="clr-namespace:GettingStarted"  
                  xmlns:border="clr-namespace:Syncfusion.XForms.Border;assembly=Syncfusion.Core.XForms"  
                 x:Class="GettingStarted.MainPage">  
        <ContentPage.Content >  
            <StackLayout  BackgroundColor="Yellow">  
                <Grid Grid.Row="1" BackgroundColor="Transparent">  
                    <Grid.RowDefinitions>  
                        <RowDefinition Height="Auto" />  
                    </Grid.RowDefinitions>  
      
                  <border:SfBorder Grid.Row="1" Margin="10" BorderColor="Black" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" CornerRadius="25">  
                        <Label Grid.Row="2" Text="Source : www.u.ae"  BackgroundColor="Black" TextColor="White" HorizontalOptions="FillAndExpand" HorizontalTextAlignment="Start" VerticalOptions="FillAndExpand" VerticalTextAlignment="Center" FontSize="Medium" />  
                    </border:SfBorder>  
                </Grid>  
            </StackLayout>  
        </ContentPage.Content>  
    </ContentPage>  
    

    The result is black color just as you set.

    72218-image.png

    Best Regards,

    Jessie Zhang

    ---
    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.