Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Page Class

Page encapsulates a page of content that can be navigated to and hosted by Windows Internet Explorer, NavigationWindow, and Frame.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[ContentPropertyAttribute("Content")] 
public class Page : FrameworkElement, IAddChild
/** @attribute ContentPropertyAttribute("Content") */ 
public class Page extends FrameworkElement implements IAddChild
ContentPropertyAttribute("Content") 
public class Page extends FrameworkElement implements IAddChild
<Page>
  Content
</Page>

Page encapsulates a page of content that can be navigated, and has the following key members:

Lifetime Management: KeepAlive.

Navigation: NavigationService.

Appearance: Background, Content, FontFamily,FontSize, Foreground, ShowsNavigationUI, Template, Title.

Host Window Appearance: WindowHeight, WindowWidth, WindowTitle.

A page can be defined using markup, markup and code-behind, or code, and is the preferred way to package content for navigation, because it:

  • Is easy to define, reuse and manage.

  • Can access and use the NavigationService that navigated to it.

  • Can alter the title, width, height, and navigation UI of its host window (WindowTitle, WindowWidth, WindowHeight, ShowsNavigationUI).

  • Has designer support in Microsoft Visual Studio.

A page can be hosted from Window, NavigationWindow, Frame, UserControl, or from a browser. To be hosted, a page can be:

  • The direct child of a Window, NavigationWindow, Frame, UserControl root element in XAML.

  • Created as a page instance and set as the value of the Content property of Window, NavigationWindow, Frame, UserControl (for either markup and code-behind pages or code pages).

  • Set as the uniform resource identifier (URI) source of the Source property of either NavigationWindow or Frame (for either markup pages or markup and code-behind pages).

  • Set as the StartupUri in a standalone application, which causes Application to open a NavigationWindow and navigate it to the specified page.

  • Set as the StartupUri in an XBAP, which causes Application to navigate Internet Explorer to the specified page.

An application typically has two or more pages, which can be navigated between using the following mechanisms:

  • Declaratively by using Hyperlink.

  • Programmatically by using NavigationService.

  • Visually by using the navigation UI of the host, including Windows Internet Explorer, NavigationWindow, and Frame.

For structured navigation using page functions (PageFunction), see Structured Navigation Overview and Navigation Topologies Overview.

The following example shows how a standard page is defined using only markup:

<Page 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    Title="Markup Page">
  <!-- Page Content Goes Here -->
</Page>

The following example shows how a standard page is defined using only code:

using System.Windows.Controls;

public class CodePage : Page
{
    public CodePage() {}
}

The following example shows how a standard page is defined using a combination of markup and code-behind.

<Page 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="MarkupAndCodeBehindPage"
    Title="Markup And Code-Behind Page">
  <!-- Page Content Goes Here -->
</Page>

using System.Windows.Controls;

public partial class MarkupAndCodeBehindPage : Page
{
    public MarkupAndCodeBehindPage()
    {
        InitializeComponent();
    }
}

System.Object
   System.Windows.Threading.DispatcherObject
     System.Windows.DependencyObject
       System.Windows.Media.Visual
         System.Windows.UIElement
           System.Windows.FrameworkElement
            System.Windows.Controls.Page
               System.Windows.Navigation.PageFunctionBase
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.