Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to give title to WPF pages

Tags:

c#

wpf

xaml

It is possible to give the title to WPF window through XAML code itself at design time and it is showing the title to window at runtime.

the code in the XAML is like

Window1.Title="FormulaBuilder"

For the WPF pages also it is given in the XAML code like

Page1.Title="EmployeeMaster"

But it is not showing the title at Runtime

Then I tried to give the title through C# coding

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

But it is not showing the title at runtime.

like image 450
Lukman Avatar asked Mar 01 '10 06:03

Lukman


People also ask

How do I change the title of a window in WPF?

How do I programmatically change the Title in a wpf window? Change the Title from "Contacts" to "Something new" when the program finds new information as it starts. You should use binding. Bind the title property of window to a property of your DataContext.

Can you use C++ with WPF?

You can use WPF with C++/CLI. It is a . NET API, however, so it requires the . NET Framework.

What is the difference between page and window in WPF?

Window is the root control that must be used to hold/host other controls (e.g. Button) as container. Page is a control which can be hosted in other container controls like NavigationWindow or Frame. Page control has its own goal to serve like other controls (e.g. Button). Page is to create browser like applications.

How do I change the color of the title bar in WPF?

You can change the background colour of the TilteBar by overriding the RibbonWindow template in App. Xaml and change the value of Background property in TitleBarStyleKey. The following code example demonstrates the same.


1 Answers

From the documentation (Page.Title):

The value of the Title property is not displayed by Page, nor is it displayed from the title bar of the window that is hosting a Page. Instead, you set WindowTitle to change the title of a host window.

Title 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:

* 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.

So, it seems you should try using Page.WindowTitle. You can do this from xaml or code:

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

or

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

Note that:

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.

like image 169
Benny Jobigan Avatar answered Sep 21 '22 02:09

Benny Jobigan