Hi Anson,
We suspect that you have initialized the MainPage as
AppShell in App.xaml.cs, we suggest you to set the MainPage as page which you
want to get the size , Please refer the below code snippet for more
understanding
Code snippet:
|
public partial class App :
Application
{
public App()
{
InitializeComponent();
MainPage = new
MainPage();
}
}
|
Also If you want to
initialize
the MainPage as AppShell , you can get the width from the mainPage, we have
attached the code snippet for more reference.
Code snippet:
|
protected override void OnSizeAllocated(double width, double height)
{
base.OnSizeAllocated(width,
height);
if (width > 0 &&
pageWidth != width)
{
var size = this.Width /
listView.ItemSize;
gridLayout.SpanCount = (int)size;
listView.LayoutManager = gridLayout;
}
}
|
If you still facing the issue , please share the details of
ContentPage and listview details which will be more helpful for us to find the
solution as soon as possible.
Regards,
Suthi Yuvaraj.