DynamicDocumentPaginator.GetPageNumberAsync Method (ContentPosition, Object)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Asynchronously, returns (through the This method raises the GetPageNumberCompleted event) the zero-based page number of the specified ContentPosition.

Namespace:   System.Windows.Documents
Assembly:  PresentationCore (in PresentationCore.dll)

public virtual void GetPageNumberAsync(
	ContentPosition contentPosition,
	object userState


Type: System.Windows.Documents.ContentPosition

The content position element to return the page number of.

Type: System.Object

A unique identifier for the asynchronous task.

This overload of the method makes it possible to cancel this asynchronous operation without cancelling all asynchronous operations.

This method raises the GetPageNumberCompleted event.

The following steps illustrate how to retrieve the page number of a given contentPosition asynchronously.

  1. Create a GetPageNumberCompletedEventHandler delegate and add it to be notified of GetPageNumberCompleted events.

  2. Call GetPageNumberAsync(ContentPosition, Object) specifying the contentPosition desired and a unique userState object that will be used to identify the asynchronous task.

  3. When the event occurs and the delegate is called, compare the event's GetPageNumberCompletedEventArgs.UserState property with the original GetPageNumberAsync userState parameter.

  4. When the GetPageNumberCompletedEventArgs.UserState property matches the original GetPageNumberAsync(ContentPosition, Object) userState, the operation is complete and the page number is ready. (The GetPageNumberCompletedEventArgs.ContentPosition property will also match the original GetPageNumberAsync(ContentPosition, Object) contentPosition parameter.)

  5. The GetPageNumberCompletedEventArgs.PageNumber property contains the zero-based page number of the specified contentPosition.

GetPageNumber provides similar functionality as GetPageNumberAsync, but for synchronous operation.

.NET Framework
Available since 3.0
Return to top