2010-03-01 29 views
2

在设计时可以通过XAML代码本身为WPF窗口赋予标题,并且它在运行时显示窗口标题。如何为WPF页面提供标题

在XAML代码如下

Window1.Title="FormulaBuilder" 

对于WPF页面还它在XAML代码中给出像

Page1.Title="EmployeeMaster" 

但它没有显示在运行时

标题

然后我试着通过C#编码给出标题

Page1 obj=new Page1(); 
obj.Title="EmployeeMaster"; 

但它没有在运行时显示标题。

回答

0

试试这一个

<Window 
    x:Class="MyWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="The Title" 
    Height="300" 
    Width="300"> 
</window> 
+2

-1。 OP正在寻找如何根据“Page”的标题设置窗口标题。 – 2010-03-01 06:41:33

+1

这不适用于页面问题要求页面(而不是窗口)。 – Paparazzi 2011-10-12 23:50:15

7

从文档(Page.Title):

Title属性的值 不显示的页面,也不是从标题显示 提供页面的 窗口的酒吧。 取而代之的是,您设置了WindowTitle至 更改主机窗口的标题。

标题也可用于生成 导航历史的名称 条目的导航内容为 。下面的数据 件用于自动地构建 导航历史记录条目名称,在 位次:

* The attached Name attribute. 
* The Title property. 
* The WindowTitle property and the uniform resource identifier (URI) for the current page 
* The uniform resource identifier (URI) for the current page. 

所以,看来你应该尝试使用Page.WindowTitle

<Page WindowTitle="Page Title" ... > 
    ... 
</Page> 

Page myPage = new Page(); 
myPage.WindowTitle = "Page Title"; 

需要注意的是:

的页面必须是最上位的内容在窗口WINDOWTITLE有一个可以从XAML或代码做到这一点影响;例如,如果页面在框架内托管,则设置WindowTitle不会更改主机窗口的标题。

0

对于页,我们假设用户的 “标题” 属性

<Page Title="Page Title Goes here" ... > ...</Page> 
相关问题