NiAu
NiAu

Reputation: 627

Xamarin Forms Listview row width

Is there a way in Xamarin Forms to set the width of a listview row and not to expand it over the entire screen? I have tried the RequestWidth of the Listview and also worked with Grid and Layouts in ListView.

Upvotes: 0

Views: 2379

Answers (1)

irreal
irreal

Reputation: 2296

The width of a row inside the listview will always take up the entire width of the listview itself. There is no way to have extra space between the end of a Row and the edge of the listview, nor would that make any sense.

What you can do is make the listview itself smaller. For this, you need to give it a position that is NOT "Fill". It's HorizontalLayoutOptions needs to be either Start, Center or End in order to NOT take the entire width.

You can also use StartAndExpand / CenterAndExpand / EndAndExpand if you want the list view to try and force it's parent control to take as much width as is available, even though the list view will still just take the space it "needs" or requests using WidthRequest.

Hope that clears it up a bit, please refer to the Layout documentation for Xamarin.Forms if you're stuck.

Upvotes: 1

Related Questions