I\'m using StackLayout and ListView to show some part of a view, but the ListView takes more space than I need, and leaves a blank space between the last row of the list and
Thank you guys, but nothing worked for me. The solution that I thought by myself surely isn't the best one, but it works for me.....
At the XAML I left an empty StackLayout like this:
And then, in the .cs file, I called this method after InitializeComponent() method:
private void setUpContacts(Establishment establishment)
{
foreach(Contact contact in establishment.Contacts)
{
StackLayout row = new StackLayout
{
Orientation = StackOrientation.Vertical
};
row.Children.Add(new Label
{
TextColor = Color.Gray,
Text = string.Format("{0}:", contact.StringType)
});
row.Children.Add(new Label
{
TextColor = Color.Black,
FontAttributes = FontAttributes.Bold,
Text = contact.Value,
});
row.GestureRecognizers.Add(new TapGestureRecognizer {
Command = new Command(() => OnContactTapped(row, contact))
});
ContactsList.Children.Add(row);
}
}
I made this because the list isn't a really ListView, since I don't need scrolling functions directly in the list, it is just another part of the view. It won't cause any performance problem, I think, because it will have a small number of items (maximum 5). I'm marking this one as the correct answer to help others with this problem.
Please, if this is a solution that does not work for others, let me know and I'll find another way to do this.