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
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Navigation;

namespace IPCCSSampleCSharp
    public partial class HomePage: Page, IProvideCustomContentState
        public HomePage()

            // Display initial read count
            this.readCountLabel.Content = 1;

        CustomContentState IProvideCustomContentState.GetContentState()
            // Store vertical position of scroll viewer with navigation history entry
            // before being navigated to next page.
            return new CustomPageContentState(this.documentScrollViewer.VerticalOffset, int.Parse(this.readCountLabel.Content.ToString()));