Hi Ali,
The reported scenario occurs when setting the ItemSize in the SizeChanged event. Hence, we suggest you can overcome the reported scenario by setting the ItemSize as mentioned below,
|
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
var lst = new List<TestModel>()
{
…
};
listView.ItemsSource = lst;
if (Device.RuntimePlatform == Device.UWP)
{
listView.SizeChanged += (a, b) => DeviceDisplay_MainDisplayInfoChanged(null, new DisplayInfoChangedEventArgs(DeviceDisplay.MainDisplayInfo));
listView.ItemSize = 100;
}
}
private void DeviceDisplay_MainDisplayInfoChanged(object p, DisplayInfoChangedEventArgs e)
{
if (Device.Idiom.HasFlag(TargetIdiom.Desktop))
{
if (listView.Width < 0) return;
layout.SpanCount = (int)(listView.Width / e.DisplayInfo.Density / 100);
return;
}
}
} |
Please let us know if you need further assistance.
Lakshmi Natarajan