Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separators in Xamarin.Forms

I'd like to use horizontal separator lines in a form. As far as I found out, Xamarin.Forms doesn't provide one.

Could someone provide a snippet for separators?

UPDATE 1

According to Jason's proposal, this looks fine:

// draws a separator line and space of 5 above and below the separator     new BoxView() { Color = Color.White, HeightRequest = 5  }, new BoxView() { Color = Color.Gray, HeightRequest = 1, Opacity = 0.5  }, new BoxView() { Color = Color.White, HeightRequest = 5  }, 

Renders the below separator line:

enter image description here

like image 642
SteAp Avatar asked Jun 08 '14 01:06

SteAp


People also ask

How do you use lines in Xamarin form?

To draw a line, create a Line object and set its X1 and Y1 properties to its start point, and its X2 and Y properties to its end point. In addition, set its Stroke property to a Brush -derived object because a line without a stroke is invisible. For more information about Brush objects, see Xamarin. Forms Brushes.

Is Xamarin forms being deprecated?

In May 2020, Microsoft announced that Xamarin. Forms, a major component of its mobile app development framework, would be deprecated in November 2021 in favour of a new . Net based product called MAUI - Multiform App User Interface.


1 Answers

You might try using BoxView

// sl is a StackLayout sl.Children.Add(new BoxView() { Color = Color.Black, WidthRequest = 100, HeightRequest = 2 }); 

although in my test, the width request is not being followed. This may be a bug, or other settings might be interfering with it.

like image 141
Jason Avatar answered Sep 20 '22 12:09

Jason