Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
/** @property */ public boolean get_KeepAlive () /** @property */ public void set_KeepAlive (boolean value)
public function get KeepAlive () : boolean public function set KeepAlive (value : boolean)
Property ValueA Boolean value that is true to retain an instance of a Page in navigation history; otherwise, false (the default).
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 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" WindowTitle="HomePage" KeepAlive="True" > ... </Page>
<Page x:Class="CSharp.HomePage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" WindowTitle="HomePage" > ... </Page>
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 EditionThe Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.