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.

 
 
 
 
 
(0)
6,756 times
Add to favorites
2/1/2011
E-mail Twitter del.icio.us 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()
        {
            InitializeComponent();

            // 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()));
        }
    }
}