mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-05 07:56:11 +02:00
* Reset branch for WPF changes * Convert BMP to PNG; fix link-out-of-scope err * Add snippets for WPF... 6794 files!!!! * Add missing snippets * update file updated between migration * Fix paths to include * update breadcrumb and toc * fix index links * fix index links * fix index links * fix markdown
33 lines
2.4 KiB
Markdown
33 lines
2.4 KiB
Markdown
---
|
|
title: "How to: Navigate Through the Objects in a Data CollectionView"
|
|
ms.date: "03/30/2017"
|
|
dev_langs:
|
|
- "csharp"
|
|
- "vb"
|
|
helpviewer_keywords:
|
|
- "CollectionView [WPF], navigating through objects"
|
|
- "data binding [WPF], navigating through objects in data CollectionView"
|
|
- "navigating through objects in data CollectionView [WPF]"
|
|
ms.assetid: fcd37590-bce1-4ac9-8b74-3b96c7458b8a
|
|
---
|
|
# How to: Navigate Through the Objects in a Data CollectionView
|
|
Views allow the same data collection to be viewed in different ways, depending on sorting, filtering, or grouping. Views also provide a current record pointer concept and enable moving the pointer. This example shows how to get the current object as well as navigate through the objects in a data collection using the functionality provided in the <xref:System.Windows.Data.CollectionView> class.
|
|
|
|
## Example
|
|
In this example, `myCollectionView` is a <xref:System.Windows.Data.CollectionView> object that is a view over a bound collection.
|
|
|
|
In the following example, `OnButton` is an event handler for the `Previous` and `Next` buttons in an application, which are buttons that allow the user to navigate the data collection. Note that the <xref:System.Windows.Data.CollectionView.IsCurrentBeforeFirst%2A> and <xref:System.Windows.Data.CollectionView.IsCurrentAfterLast%2A> properties report whether the current record pointer has come to the beginning and the end of the list respectively so that <xref:System.Windows.Data.CollectionView.MoveCurrentToFirst%2A> and <xref:System.Windows.Data.CollectionView.MoveCurrentToLast%2A> can be called as appropriately.
|
|
|
|
The <xref:System.Windows.Data.CollectionView.CurrentItem%2A> property of the view is cast as an `Order` to return the current order item in the collection.
|
|
|
|
[!code-csharp[CollectionView#OnButton](~/samples/snippets/csharp/VS_Snippets_Wpf/CollectionView/CSharp/Page1.xaml.cs#onbutton)]
|
|
[!code-vb[CollectionView#OnButton](~/samples/snippets/visualbasic/VS_Snippets_Wpf/CollectionView/VisualBasic/Page1.xaml.vb#onbutton)]
|
|
|
|
## See also
|
|
|
|
- [Data Binding Overview](/dotnet/desktop-wpf/data/data-binding-overview)
|
|
- [Sort Data in a View](how-to-sort-data-in-a-view.md)
|
|
- [Filter Data in a View](how-to-filter-data-in-a-view.md)
|
|
- [Sort and Group Data Using a View in XAML](how-to-sort-and-group-data-using-a-view-in-xaml.md)
|
|
- [How-to Topics](data-binding-how-to-topics.md)
|