Remember A Single Set of State Across Page Instances

This sample illustrates how to remember multiple items of page state across page instances by using IProvideCustomContentState and CustomContentState. Building the Sample Install the Windows Software Development Kit (SDK) and open its build environment command window.

6,756 times
Add to favorites
E-mail Twitter Digg Facebook
Imports System
Imports System.ComponentModel
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Navigation

Public Class HomePage
    Inherits Page

    Implements IProvideCustomContentState

    ' Methods
    Public Sub New()


        ' Display initial read count
        Me.readCountLabel.Content = 1

    End Sub

    Function GetContentState() As CustomContentState Implements IProvideCustomContentState.GetContentState

        ' Store vertical position of scroll viewer with navigation history entry
        ' before being navigated to next page.
        Return New CustomPageContentState(Me.documentScrollViewer.VerticalOffset, Integer.Parse(Me.readCountLabel.Content.ToString()))

    End Function

End Class