Category / Section
How to load xamarin.forms listview for full height without virtualization?
1 min read
You can load the listview with full height without virtualization by setting the TotalExtent property to ListView HeightRequest property. Use the HeightRequest property when the list view contains more elements in the same page.
public class ListViewBehavior : Behavior<SfListView> { private SfListView listView; protected override void OnAttachedTo(SfListView bindable) { listView = bindable; listView.Loaded += OnListViewLoaded; base.OnAttachedTo(bindable); } private void OnListViewLoaded(object sender, ListViewLoadedEventArgs e) { var container = listView.GetVisualContainer(); var extent = (double)container.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name == "TotalExtent").GetValue(container); listView.HeightRequest = extent; } protected override void OnDetachingFrom(SfListView bindable) { listView.Loaded -= OnListViewLoaded; base.OnDetachingFrom(bindable); } }
Click here to download the sample.