2

I'm trying to implement a Comments Section at the end of a page, which I want to load comments as you scroll down the page. Currently I have the ListView scrollviewer as the means of scrolling the content. However, this feels disjointed as there are two scrollbars at the end of the page, and if the Main Scrollviewer hasn't scrolled all the way down, it gets confusing.

Example

The Comments Control is a separate UserControl, where the Comments ListView is in a Pivot control. I have a Dependency Property for a ScrollViewer, which I use with x:bind to fetch from the Visual Tree of the Page.

Is there a way to get these scrollviewers to act as one? With one Scrollbar, and the scrolling of the Page causing ItemSource to incrementally load?

I am using the IncrementalLoadingCollection from UWP Community Toolkit as the ISupportIncrementalLoading object.

Bart
  • 9,925
  • 7
  • 47
  • 64
William Bradley
  • 543
  • 5
  • 14
  • So just to make sure I'm understanding, you're trying to invoke invoke virtualization within the ListView(comments) from it's parent ScrollViewer's scrolling beyond it's place in the VerticalOffset? – Chris W. Apr 18 '17 at 17:16
  • Yes, essentially, I would like it so that when you scroll the parent ScrollViewer, more of the ListView is revealed (as if there was only one Scrollviewer), and at the same time virtualisation occurs as the scroll happens. If you remove the MaxHeight I set on the Grid I set inside the Pivot control, where the ListView is located, it acts as one scrollviewer, except that it loads the whole list of items at once (defeating the point of ISupportIncrementialLoading). – William Bradley Apr 19 '17 at 01:48
  • Similar to this: http://stackoverflow.com/questions/22946009/isupportincrementalloading-inside-scrollviewer-not-supported – William Bradley Apr 19 '17 at 01:54
  • IMO don't use a pivot control since it limits you so much. Do what Twitter app does on a user profile. – Quincy Jun 02 '17 at 18:07
  • @Quincy It looks like they aren't using a Pivot, but have a listview that switches the source? Something like that? – William Bradley Jun 10 '17 at 08:32
  • Yeah. It's a listview. They have all the stuff above tweets inside the listview's header. Then the items of the listview are tweets. – Quincy Jun 10 '17 at 12:12

1 Answers1

0

I think you are mistaking the approach why instead of using x:bind, dont you try to use x:Phase, without phases every element is rendered at once but with them you can control when to render them.

also UWP has x:DeferLoadStrategy="Lazy"

Reduce the number of elements at startup, Declare the UIElement-derived items (or containers) you don't want rendered

another ways to realize an element FindName() GetTemplatedChild() (for ControlTemplate) Storyboard & VisualStates (because of FindName)

of course this isnt free a lightweight proxy element is created,events are hooked up after realized, Binding is completed after realized (including x:Bind)

thats my best answer if you could have shared some code I might be able to deepen more in the subject.

Hopefully my answer helps you!!

  • My Listview contains UserControl Elements, so x:Phase isn't that useful. I want to use ISupportIncremential Loading, as it allows me to collect more Comments from the Server when scrolling. The only reason why I use x:bind for the Main Scrollviewer, is so that I can pull it into the logic contained in the CommentsControl UserControl. Where I would check for scrolling events (But I don't know how to get it to dynamically resize with Inertia). – William Bradley Apr 19 '17 at 03:04