VirtualizingStackPanel VirtualizingStackPanel VirtualizingStackPanel Class

Definition

Arranges and virtualizes content on a single line that is oriented either horizontally or vertically. Can only be used to display items in an ItemsControl.

public sealed class VirtualizingStackPanel : OrientedVirtualizingPanel, IVirtualizingStackPanel, IVirtualizingStackPanelOverridespublic sealed class VirtualizingStackPanel : OrientedVirtualizingPanel, IVirtualizingStackPanel, IVirtualizingStackPanelOverridesPublic NotInheritable Class VirtualizingStackPanel Inherits OrientedVirtualizingPanel Implements IVirtualizingStackPanel, IVirtualizingStackPanelOverrides
<VirtualizingStackPanel .../>
-or-
<VirtualizingStackPanel ...>
  oneOrMoreChildren
</VirtualizingStackPanel>

Inheritance
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Inherited Members

Inherited properties

Inherited events

Inherited methods

Windows.UI.Xaml.Controls.Primitives.OrientedVirtualizingPanel.GetInsertionIndexes(Windows.Foundation.Point,System.Int32,System.Int32)Windows.UI.Xaml.Controls.Primitives.OrientedVirtualizingPanel.GetInsertionIndexes(Windows.Foundation.Point,System.Int32,System.Int32)Windows.UI.Xaml.Controls.Primitives.OrientedVirtualizingPanel.GetInsertionIndexes(Windows.Foundation.Point,System.Int32,System.Int32)
Windows.UI.Xaml.Controls.Primitives.OrientedVirtualizingPanel.GetRegularSnapPoints(Windows.UI.Xaml.Controls.Orientation,Windows.UI.Xaml.Controls.Primitives.SnapPointsAlignment,System.Single)Windows.UI.Xaml.Controls.Primitives.OrientedVirtualizingPanel.GetRegularSnapPoints(Windows.UI.Xaml.Controls.Orientation,Windows.UI.Xaml.Controls.Primitives.SnapPointsAlignment,System.Single)Windows.UI.Xaml.Controls.Primitives.OrientedVirtualizingPanel.GetRegularSnapPoints(Windows.UI.Xaml.Controls.Orientation,Windows.UI.Xaml.Controls.Primitives.SnapPointsAlignment,System.Single)

Remarks

VirtualizingStackPanel can only be used to display items in an ItemsControl. A primary scenario for VirtualizingStackPanel is that it provides the items panel template behavior for FlipView and ListBox in default templates.

Note

Starting in Windows 8.1, ItemsStackPanel is used as the default ItemsPanel for ListView. If you modify the ItemsPanel, we recommend you use ItemsStackPanel or ItemsWrapGrid instead of VirtualizingStackPanel or WrapGrid.

VirtualizingStackPanel attached properties

VirtualizingStackPanel is the host service class for several attached properties that control or report the virtualization mode:

VirtualizingStackPanel.VirtualizationMode is an Extensible Application Markup Language (XAML) attached property, and child elements set this property in markup to declare how the item should be virtualized when included as a VirtualizingStackPanel child element.

VirtualizingStackPanel.IsVirtualizing uses the attached property model as a property store, but does not support a Extensible Application Markup Language (XAML) usage. Instead, the property serves as a sentinel that any VirtualizingStackPanel child element can check to determine whether that child is currently being represented as virtualized. To find out if an item is being virtualized, call GetIsVirtualizing, passing the item as the input parameter.

Constructors

VirtualizingStackPanel() VirtualizingStackPanel() VirtualizingStackPanel()

Initializes a new instance of the VirtualizingStackPanel class.

public VirtualizingStackPanel()public VirtualizingStackPanel()Public Sub New()
Attributes

Properties

AreScrollSnapPointsRegular AreScrollSnapPointsRegular AreScrollSnapPointsRegular

Gets or sets a value that indicates whether the generated snap points used for panning in the VirtualizingStackPanel are equidistant from each other.

public bool AreScrollSnapPointsRegular { get; set; }public bool AreScrollSnapPointsRegular { get; set; }Public ReadWrite Property AreScrollSnapPointsRegular As bool
<VirtualizingStackPanel AreScrollSnapPointsRegular="bool" .../>
Value
bool bool bool

true if the snap points in the VirtualizingStackPanel are equidistant from each other; otherwise, false.

Attributes

AreScrollSnapPointsRegularProperty AreScrollSnapPointsRegularProperty AreScrollSnapPointsRegularProperty

Identifies the AreScrollSnapPointsRegular dependency property.

public static DependencyProperty AreScrollSnapPointsRegularProperty { get; }public static DependencyProperty AreScrollSnapPointsRegularProperty { get; }Public Static ReadOnly Property AreScrollSnapPointsRegularProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the AreScrollSnapPointsRegular dependency property.

Attributes

IsVirtualizingProperty IsVirtualizingProperty IsVirtualizingProperty

Identifies the VirtualizingStackPanel.IsVirtualizing attached property.

public static DependencyProperty IsVirtualizingProperty { get; }public static DependencyProperty IsVirtualizingProperty { get; }Public Static ReadOnly Property IsVirtualizingProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the VirtualizingStackPanel.IsVirtualizing attached property.

Attributes

Remarks

VirtualizingStackPanel.IsVirtualizing is an atypical attached property because it does not have a Set accessor, and thus is not really a XAML attached property with a markup usage. Instead, VirtualizingStackPanel.IsVirtualizing functions as a sentinel whereby child elements can query the VirtualizingStackPanel parent, and determine whether virtualization is being used. This might be important information for layout logic or further virtualization logic that is used by the child element itself.

Orientation Orientation Orientation

Gets or sets a value that describes the horizontal or vertical orientation of stacked content.

public Orientation Orientation { get; set; }public Orientation Orientation { get; set; }Public ReadWrite Property Orientation As Orientation
<VirtualizingStackPanel Orientation="Horizontal"/>
- or -
<VirtualizingStackPanel Orientation="Vertical"/>
Value
Orientation Orientation Orientation

The Orientation of child content, as a value of the enumeration. The default is Vertical.

Attributes

OrientationProperty OrientationProperty OrientationProperty

Identifies the Orientation dependency property.

public static DependencyProperty OrientationProperty { get; }public static DependencyProperty OrientationProperty { get; }Public Static ReadOnly Property OrientationProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the Orientation dependency property.

Attributes

VirtualizationModeProperty VirtualizationModeProperty VirtualizationModeProperty

Identifies the VirtualizingStackPanel.VirtualizationMode XAML attached property.

public static DependencyProperty VirtualizationModeProperty { get; }public static DependencyProperty VirtualizationModeProperty { get; }Public Static ReadOnly Property VirtualizationModeProperty As DependencyProperty
Attributes

Methods

GetIsVirtualizing(DependencyObject) GetIsVirtualizing(DependencyObject) GetIsVirtualizing(DependencyObject)

Gets a value that determines whether an item is currently being virtualized as part of an items set where the ItemsPanel is templated with a VirtualizingStackPanel.

public static bool GetIsVirtualizing(DependencyObject o)public static bool GetIsVirtualizing(DependencyObject o)Public Static Function GetIsVirtualizing(o As DependencyObject) As bool
Parameters
o
DependencyObject DependencyObject DependencyObject

The object item where you want to determine the current virtualization state.

Returns
bool bool bool

true if the item specified by o is currently virtualizing its content; otherwise, false.

Attributes

Remarks

VirtualizingStackPanel.IsVirtualizing uses the attached property model as a property store, but does not support a XAML usage. Instead, the property serves as a sentinel that any VirtualizingStackPanel child element can check to determine whether that child is currently being represented as virtualized. To find out if an item is being virtualized, call GetIsVirtualizing, passing the item as the input parameter.

GetVirtualizationMode(DependencyObject) GetVirtualizationMode(DependencyObject) GetVirtualizationMode(DependencyObject)

Gets the VirtualizingStackPanel.VirtualizationMode XAML attached property value for the specified target element.

public static VirtualizationMode GetVirtualizationMode(DependencyObject element)public static VirtualizationMode GetVirtualizationMode(DependencyObject element)Public Static Function GetVirtualizationMode(element As DependencyObject) As VirtualizationMode
Parameters
element
DependencyObject DependencyObject DependencyObject

The object from which the VirtualizationMode is read.

Returns

One of the enumeration values that specifies whether the object uses container recycling.

Attributes

Remarks

For more info, see the VirtualizingStackPanel.VirtualizationMode attached property.

OnCleanUpVirtualizedItem(CleanUpVirtualizedItemEventArgs) OnCleanUpVirtualizedItem(CleanUpVirtualizedItemEventArgs) OnCleanUpVirtualizedItem(CleanUpVirtualizedItemEventArgs)

Called when an item that is hosted by the VirtualizingStackPanel is re-virtualized.

protected virtual void OnCleanUpVirtualizedItem(CleanUpVirtualizedItemEventArgs e)protected virtual void OnCleanUpVirtualizedItem(CleanUpVirtualizedItemEventArgs e)Protected Overridable Function OnCleanUpVirtualizedItem(e As CleanUpVirtualizedItemEventArgs) As void
Parameters
Attributes

SetVirtualizationMode(DependencyObject, VirtualizationMode) SetVirtualizationMode(DependencyObject, VirtualizationMode) SetVirtualizationMode(DependencyObject, VirtualizationMode)

Sets the VirtualizingStackPanel.VirtualizationMode XAML attached property on the specified target element.

public static void SetVirtualizationMode(DependencyObject element, VirtualizationMode value)public static void SetVirtualizationMode(DependencyObject element, VirtualizationMode value)Public Static Function SetVirtualizationMode(element As DependencyObject, value As VirtualizationMode) As void
Parameters
element
DependencyObject DependencyObject DependencyObject

The target element.

value
VirtualizationMode VirtualizationMode VirtualizationMode

One of the enumeration values that specifies whether element uses container recycling.

Attributes

Remarks

For more info, see the VirtualizingStackPanel.VirtualizationMode attached property.

Events

CleanUpVirtualizedItemEvent CleanUpVirtualizedItemEvent CleanUpVirtualizedItemEvent

Occurs when an item that is hosted by the VirtualizingStackPanel is re-virtualized.

public event CleanUpVirtualizedItemEventHandler CleanUpVirtualizedItemEventpublic event CleanUpVirtualizedItemEventHandler CleanUpVirtualizedItemEventPublic Event CleanUpVirtualizedItemEvent
<VirtualizingStackPanel CleanUpVirtualizedItemEvent="eventhandler" />
Attributes

See Also