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
I had issues with Yehor Hromadskyi's solution.
Here are the changes to the code to fix those issues
public class ListViewHeightBehavior : Behavior
{
private ListView _listView;
public static readonly BindableProperty ExtraSpaceProperty =
BindableProperty.Create(nameof(ExtraSpace),
typeof(double),
typeof(ListViewHeightBehavior),
0d);
public static readonly BindableProperty DefaultRowHeightProperty =
BindableProperty.Create(nameof(DefaultRowHeight),
typeof(int),
typeof(ListViewHeightBehavior),
40);
public int DefaultRowHeight
{
get => (int)GetValue(DefaultRowHeightProperty);
set => SetValue(DefaultRowHeightProperty, value);
}
public double ExtraSpace
{
get { return (double)GetValue(ExtraSpaceProperty); }
set { SetValue(ExtraSpaceProperty, value); }
}
protected override void OnAttachedTo(ListView bindable)
{
base.OnAttachedTo(bindable);
_listView = bindable;
_listView.PropertyChanged += (s, args) =>
{
var count = _listView.ItemsSource?.Cast