Virtualizing​Panel Class

Definition

Provides a framework for Panel elements that virtualize their child data collection. This is an abstract class.

public abstract class VirtualizingPanel : System.Windows.Controls.Panel
Inheritance
Derived

Inherited Members

System.Object

System.Windows.Controls.Panel

System.Windows.DependencyObject

System.Windows.FrameworkElement

System.Windows.Media.Visual

System.Windows.Threading.DispatcherObject

System.Windows.UIElement

Examples

The following example demonstrates how to use the derived VirtualizingStackPanel class in Extensible Application Markup Language (XAML).

<StackPanel DataContext="{Binding Source={StaticResource Leagues}}">
    <TextBlock Text="{Binding XPath=@name}" FontFamily="Arial" FontSize="18" Foreground="Black"/>
        <ListBox VirtualizingStackPanel.IsVirtualizing="True" 
                 ItemsSource="{Binding XPath=Team}" 
                 ItemTemplate="{DynamicResource NameDataStyle}"/>      
</StackPanel>

Remarks

In this context, "virtualize" refers to a technique by which a subset of user interface (UI) elements are generated from a larger number of data items based on which items are visible on the screen. It is intensive, both in terms of memory and processor, to generate a large number of UI elements when only a few may be on the screen at a given time. A panel that inherits from VirtualizingPanel, such as the VirtualizingStackPanel, calculates visible items and works with the ItemContainerGenerator from an ItemsControl (such as ListBox or ListView) to only create UI elements for visible items.

The following lists describes cases when the VirtualizingPanel cannot virtualize item containers:

  • The ItemsControl contains item containers of different types. For example, a Menu might have items that use both MenuItem and Separator objects as the item containers.

  • You explicitly create the item containers to the ItemsControl. For more information about explicitly versus implicitly creating item containers, see the ItemsControl class.

When a VirtualizingPanel is virtualizing item containers, you may need to save state information that is associated with a container instead of with the data item itself. For example, if an item is contained by an Expander control, the IsExpanded state is bound to the item container, and not to the data item itself. When the Expander is reused for a new item, the current value of IsExpanded is used for the new item. In addition, the old item does not retain its IsExpanded value.

Constructors

Virtualizing​Panel()

Initializes a new instance of the VirtualizingPanel class.

Fields

Cache​Length​Property

Identifies the System.Windows.Controls.VirtualizingPanel.CacheLength attached property.

Cache​Length​Unit​Property

Identifies the System.Windows.Controls.VirtualizingPanel.CacheLengthUnit attached property.

Is​Container​Virtualizable​Property

Identifies the System.Windows.Controls.VirtualizingPanel.IsContainerVirtualizable attached property.

Is​Virtualizing​Property

Identifies the System.Windows.Controls.VirtualizingPanel.IsVirtualizing dependency property.

Is​Virtualizing​When​Grouping​Property

Identifies the System.Windows.Controls.VirtualizingPanel.IsVirtualizingWhenGrouping attached property.

Scroll​Unit​Property

Identifies the System.Windows.Controls.VirtualizingPanel.ScrollUnit attached property.

Virtualization​Mode​Property

Identifies the System.Windows.Controls.VirtualizingPanel.VirtualizationMode dependency property.

Properties

Can​Hierarchically​Scroll​And​Virtualize

Gets a value that indicates whether the VirtualizingPanel can virtualize items that are grouped or organized in a hierarchy.

Can​Hierarchically​Scroll​And​Virtualize​Core

Gets a value that indicates whether the VirtualizingPanel can virtualize items that are grouped or organized in a hierarchy.

Item​Container​Generator

Gets a value that identifies the ItemContainerGenerator for this VirtualizingPanel.

Methods

Add​Internal​Child(​UI​Element)

Adds the specified UIElement to the InternalChildren collection of a VirtualizingPanel element.

Bring​Index​Into​View(​Int32)

When implemented in a derived class, generates the item at the specified index location and makes it visible.

Bring​Index​Into​View​Public(​Int32)

Generates the item at the specified index location and makes it visible.

Get​Cache​Length(​Dependency​Object)

Gets the value of the System.Windows.Controls.VirtualizingPanel.CacheLength property.

Get​Cache​Length​Unit(​Dependency​Object)

Gets the value of the System.Windows.Controls.VirtualizingPanel.CacheLengthUnit property.

Get​Is​Container​Virtualizable(​Dependency​Object)

Gets the value of the System.Windows.Controls.VirtualizingPanel.IsContainerVirtualizable property.

Get​Is​Virtualizing(​Dependency​Object)

Gets the value of the System.Windows.Controls.VirtualizingPanel.IsVirtualizing attached property.

Get​Is​Virtualizing​When​Grouping(​Dependency​Object)

Gets the value of the System.Windows.Controls.VirtualizingPanel.IsVirtualizingWhenGrouping property.

Get​Item​Offset(​UI​Element)

Returns the position of the specified item, relative to the VirtualizingPanel.

Get​Item​Offset​Core(​UI​Element)

Returns the position of the specified item, relative to the VirtualizingPanel.

Get​Scroll​Unit(​Dependency​Object)

Gets the value of the System.Windows.Controls.VirtualizingPanel.ScrollUnit property.

Get​Virtualization​Mode(​Dependency​Object)

Returns the System.Windows.Controls.VirtualizingPanel.VirtualizationMode attached property for the specified object.

Insert​Internal​Child(​Int32, ​UI​Element)

Adds the specified UIElement to the InternalChildren collection of a VirtualizingPanel element at the specified index position.

On​Clear​Children()

Called when the collection of child elements is cleared by the base Panel class.

On​Items​Changed(​Object, ​Items​Changed​Event​Args)

Called when the Items collection that is associated with the ItemsControl for this Panel changes.

Remove​Internal​Child​Range(​Int32, ​Int32)

Removes child elements from the InternalChildren collection.

Set​Cache​Length(​Dependency​Object, ​Virtualization​Cache​Length)

Sets the System.Windows.Controls.VirtualizingPanel.CacheLength attached property.

Set​Cache​Length​Unit(​Dependency​Object, ​Virtualization​Cache​Length​Unit)

Sets the System.Windows.Controls.VirtualizingPanel.CacheLengthUnit attached property.

Set​Is​Container​Virtualizable(​Dependency​Object, ​Boolean)

Sets the System.Windows.Controls.VirtualizingPanel.IsContainerVirtualizable attached property.

Set​Is​Virtualizing(​Dependency​Object, ​Boolean)

Sets the value of the IsVirtualizingProperty attached property.

Set​Is​Virtualizing​When​Grouping(​Dependency​Object, ​Boolean)

Sets the System.Windows.Controls.VirtualizingPanel.IsVirtualizingWhenGrouping attached property.

Set​Scroll​Unit(​Dependency​Object, ​Scroll​Unit)

Sets the System.Windows.Controls.VirtualizingPanel.ScrollUnit attached property.

Set​Virtualization​Mode(​Dependency​Object, ​Virtualization​Mode)

Sets the System.Windows.Controls.VirtualizingPanel.VirtualizationMode attached property on the specified object.

Should​Items​Change​Affect​Layout(​Boolean, ​Items​Changed​Event​Args)

Returns a value that indicates whether a changed item in an ItemsControl affects the layout for this panel.

Should​Items​Change​Affect​Layout​Core(​Boolean, ​Items​Changed​Event​Args)

Returns a value that indicates whether a changed item in an ItemsControl affects the layout for this panel.