Share via


ItemsStackPanel.ItemsUpdatingScrollMode Property

Definition

Gets or sets a value that specifies scrolling behavior when the ItemsSource is updated.

public:
 property ItemsUpdatingScrollMode ItemsUpdatingScrollMode { ItemsUpdatingScrollMode get(); void set(ItemsUpdatingScrollMode value); };
ItemsUpdatingScrollMode ItemsUpdatingScrollMode();

void ItemsUpdatingScrollMode(ItemsUpdatingScrollMode value);
public ItemsUpdatingScrollMode ItemsUpdatingScrollMode { get; set; }
var itemsUpdatingScrollMode = itemsStackPanel.itemsUpdatingScrollMode;
itemsStackPanel.itemsUpdatingScrollMode = itemsUpdatingScrollMode;
Public Property ItemsUpdatingScrollMode As ItemsUpdatingScrollMode
<ItemsStackPanel ItemsUpdatingScrollMode="itemsUpdatingScrollModeMemberName" />

Property Value

A value of the enumeration. The default is KeepItemsInView.

Remarks

This property controls how the ItemsStackPanel responds when the user has scrolled the items, and new items are added to the ItemsSource.

For example, if a user scrolls down a list of emails, and the ItemsSource updates, adding a new email to the top of the list:

  • If ItemsUpdatingScrollMode is KeepItemsInView, then the scroll offset is adjusted to keep the first visible item showing at the top of the view.
  • If ItemsUpdatingScrollMode is KeepScrollOffset, then the scroll offset relative to the top of the list is maintained. As a result, the items on the screen are pushed down to account for the new item added at the top.

In other cases, like in a chat app, items are added to the bottom of the list. In this case, you can set ItemsUpdatingScrollMode to KeepLastItemInView. This adjusts the scroll offset to keep the last visible item showing at the bottom of the view. (KeepLastItemInView is available starting with Windows 10, version 1607.)

Tip

In Windows 8, the ListView control uses VirtualizingStackPanel as its default ItemsPanel; in Windows 8.1, the ListView control uses ItemsStackPanel as its default ItemsPanel. When upgrading a ListView in a Windows 8 app to use ItemsStackPanel, set the ItemsUpdatingScrollMode property to KeepScrollOffset if you need to keep the behavior of the Windows 8 ListView.

Applies to