Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Forms Controls with borders

In my Xamarin forms application I want to add borders to a Grid / StackPanel. Also the background color will be transparent. I used frame control , but when I set background color to transparent the border also not shown. Please help me?

like image 857
Aneesh.A.M Avatar asked Feb 09 '23 00:02

Aneesh.A.M


2 Answers

You basically have two possibilies, since this is not yet supported in Forms, where the first is to use BoxViews as explained on SO in this post.

Otherwise, you can wrap a StackLayout around your View (the StackLayout or Grid as you mentioned) with a BackgroundColor and Padding of 0.5 as explained here.

Let me know if you need more concrete examples.

like image 72
Demitrian Avatar answered Feb 20 '23 23:02

Demitrian


There's no Border property for GridView, but:

Just set grid.BackgroundColor to your desired border color value, then set grid.ColumnSpacing and grid.RowSpacing to some value and make sure all controls you add to the grid have own BackgroundColor set correctly.

like image 45
Daniel Luberda Avatar answered Feb 21 '23 00:02

Daniel Luberda