The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Page.KeepAlive Property

Gets or sets whether an instance of a Page is retained in navigation history. This is a dependency property.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:

public bool KeepAlive { get; set; }
/** @property */
public boolean get_KeepAlive ()

/** @property */
public void set_KeepAlive (boolean value)

public function get KeepAlive () : boolean

public function set KeepAlive (value : boolean)

<object KeepAlive="bool" .../>

Property Value

A Boolean value that is true to retain an instance of a Page in navigation history; otherwise, false (the default).

Identifier Field


Metadata Flags


When a page is first navigated to, a new instance of the Page class is created. By default, subsequent navigations to the page (using navigation UI or a Hyperlink) cause a new instance of the Page class to be created.

Sometimes, however, a page needs to remember state from one instance to the next. In these cases, WPF offers several techniques for doing so, which are covered in the following topics:

In general, you should only consider setting KeepAlive to true when your requirements for remembering state are more complex than can be easily catered to by the techniques that are discussed in these topics.


instances of pages that are defined using only code are always retained in navigation history.

The following example shows how to use XAML to retain an instance of the Page class across multiple navigations.




<Page x:Class="CSharp.HomePage"



using System;
using System.Windows;
using System.Windows.Controls;

namespace CSharp
    public partial class HomePage : Page
        public HomePage()

            // Keep this page in navigation history
            this.KeepAlive = true;


Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft