Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How could I set the length of a line to stretch in a MAUI application?

Tags:

maui

I would like to use a line in a MAUI project, and this is the documentation:

https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/shapes/line?view=net-maui-7.0

But i would like, in an horizontal line, to set that automatically the line use all the space from left to right. I don't see stretch options like another controls.

I could set a very long length, for example 10000, but I would like to know if there is a better way.

Thanks.

like image 390
Álvaro García Avatar asked Sep 19 '25 20:09

Álvaro García


1 Answers

To answer directly your question: since X2 is bindable, you can bind it to the width of itself:

<Line Stroke="Red" X2="{Binding Width, Source={RelativeSource Self}}" HorizontalOptions="Fill" StrokeThickness="3" />

enter image description here

My advice: MS has been using BoxView or BorderView for lines since forever, I guess it's better performance-wise as well. You should use the other solution instead unless you absolutely have to use Line.

like image 118
Luke Vo Avatar answered Sep 23 '25 06:09

Luke Vo