Search code examples
c#xamarin.formslabelbordercustom-renderer

How to add a border to your Xamarin Form Label?


Hello fellow Xamarin Forms users,

I already found out that borders on a label are not supported out of the box by Xamarin Froms. So after some searching is still have no clue how to make it possible. Is it possible to add a border using the custom renderer? If so does someone have an example? and if not does someone have any other out of the box idea to make this possible.

Thank you in advance


Solution

  • I was thinking a little out of the box and came up with using a boxview to use as a border. Here you have a sample of the code that I wrote:

      <StackLayout x:Name="BasicInfo" Margin="10,10,10,5" Grid.Row="0" Grid.Column="0">
        <Label Text="Basic Info" FontSize="20"/>
        <BoxView Color="Black" WidthRequest ="100" HeightRequest="1"/>
         <Label x:Name="text1" />
         <Label x:Name="text2"/>
         <Label x:Name="text3"/>
         <Label x:Name="text4"/>  
      </StackLayout>
    

    I'll also add a picture of the result it gives me: enter image description here