ListBox Grouping and Virtualization

IOuterPanel and INestedPanel

Because we will have two panels communicate with each other, I defined two interfaces, IOuterPanel and INestedPanel (sorry about the bad formatting):

public interface IOuterPanel
{
Size EstimatedViewport { get; }

double VerticalOffset { get; }

ScrollViewer ScrollOwner { get; }

void AddNestedPanel( INestedScrollingPanel nestedPanel );
}

Our grouping panel will implement this interface. The EstimatedViewport property what the inner panel will query during its layout pass to get a fairly accurate value of what the visible area is. Likewise, the nested panel(s) will use VerticalOffset to aid in figuring out which children to realize during each layout pass. We expose the ScrollOwner for the nested panel because it [the outer panel] is the one communicating with the ScrollViewer.

Finally, AddNestedPanel() will be called by any inner panels to make themselves known to the grouping panel. The grouping panel will maintain a collection of nested panels. I will elaborate on this later.

interface INestedPanel : IScrollInfo
{
IOuterPanel OuterPanel { set; }
}

Our inner, virtualizing panel will implement this interface. It derives from IScrollInfo because we want the outer panel to call the appropriate scrolling methods on it in order to ensure items are realized/unrealized correctly. I defined a property to set the OuterPanel so that this panel can query the outer panel for IOuterPanel.EstimatedViewport and IOuterPanel.VerticalOffset properties as necessary. Additionally, this way the nested panel can tell the grouping panel about itself.

So to sum up how these panels will interact with each other:

groupingpanelsummary.png

Explore posts in the same categories: WPF

Pages: 1 2 3 4 5 6 7

Tags: , , , , ,

You can comment below, or link to this permanent URL from your own site.

One Comment on “ListBox Grouping and Virtualization”

  1. Luke Says:

    Great blog post! Can you please provide more details how you reworked your solution to support sorting? I am having trouble with virtualization when grouping is enabled and can’t seem to solve this issue.


Comment:

You must be logged in to post a comment.