Page.WindowTitle Property

Definition

获取或设置 Window 的宿主 NavigationWindowPage 的标题。Gets or sets the title of the host Window or NavigationWindow of a Page.

public:
 property System::String ^ WindowTitle { System::String ^ get(); void set(System::String ^ value); };
[System.Windows.Localizability(System.Windows.LocalizationCategory.Title)]
public string WindowTitle { get; set; }
member this.WindowTitle : string with get, set
Public Property WindowTitle As String

Property Value

String

直接承载 Page 的窗口的标题。The title of a window that directly hosts the Page.

Attributes

Examples

下面的示例演示如何从页面设置窗口的标题。The following example shows how to set the title of a window from a page.

<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Page Title"
    WindowTitle="Window Title"
    >
</Page>

Remarks

默认情况下,承载页面的窗口的标题(包括 NavigationWindowWindows Internet ExplorerWindows Internet Explorer)是当前正在承载的文件的名称(如果页面松动 可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML),则为 .xaml 扩展名; 如果页面是 XAML 浏览器应用程序 (XBAP)XAML browser application (XBAP)的一部分,则为 xbap 扩展名)。By default, the title of a window that hosts a page, including NavigationWindow and Windows Internet ExplorerWindows Internet Explorer, is the name of the file that is currently being hosted (with an .xaml extension if the page is loose 可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML), or an .xbap extension if the page is part of an XAML 浏览器应用程序 (XBAP)XAML browser application (XBAP)).

页面可以通过设置其 WindowTitle 属性来更改默认值。A page can change the default by setting its WindowTitle property.

一旦页面以这种方式设置了窗口的标题,窗口的标题就不会更改,直到另一个页面设置 WindowTitle 具有不同的值。Once a page sets the title of a window in this way, the window's title does not change until another page sets WindowTitle with a different value.

Note

Page 必须是窗口中内容的最上端部分,WindowTitle 才能有效;例如,如果 PageFrame中承载,则设置 WindowTitle 不会更改主机窗口的标题。The Page must be the topmost piece of content in a window for WindowTitle to have an effect; if a Page is hosted within a Frame, for example, setting WindowTitle does not change the title of the host window.

WindowTitle 还可用于为一段导航内容生成导航历史记录项的名称。WindowTitle can also be used to generate the name of the navigation history entry for a piece of navigated content. 以下数据片段用于按优先级顺序自动构造导航历史记录项名称:The following pieces of data are used to automatically construct a navigation history entry name, in order of precedence:

  • 附加 Name 特性。The attached Name attribute.

  • 属性。The property.
  • 当前页的 WindowTitle 属性和统一资源标识符(URI)The WindowTitle property and the uniform resource identifier (URI) for the current page

  • 当前页的统一资源标识符(URI)。The uniform resource identifier (URI) for the current page.

如果已将 CustomContentState 对象与导航历史记录中的一段内容相关联,则可以通过重写 CustomContentState.JournalEntryName来指定导航历史记录元素的名称值。If you have associated a CustomContentState object with a piece of content in navigation history, you can specify the name value of a navigation history element by overriding CustomContentState.JournalEntryName.

Applies to