Forum Xamarin.Forms

How to implement pagination based on devise screen resolution?

I am quite new to Xamarin Forms, so perhaps I am overlooking something obvious. I am trying to display a list of items (in a list or grid) using pagination instead of a vertical scrollbar, i.e. if a page fits 10 items and a collection has 50 items, then there will 5 pages with Next/Previous buttons.

But how am I supposed to find out how many items fit in one page? I've found references to DisplayMetrics class, but it seems to be Android-only. So what is the recommended approach to deal with such scenarios when an application needs to do perform certain action based on screen resolution? It would be logical to expect Forms to have cross-platform approach to this.

Thanks in advance


  • GeoffArmstrongGeoffArmstrong CAMember ✭✭

    So basically something like in HTML where you have offsetWidth, clientHeight, etc.

    I mean, if you're making a ListView and you're setting the item height to 40 then it would be more obvious, but I'm guessing your items don't have a set height?

  • I don't explicitly set height on list items, but suppose I do. You said it would be more obvious, do you know how I can calculate the number of visible items in a platform independent manner?

Sign In or Register to comment.