Skip to main content

MSDN

Answered Question How do I set the page title?RSS Feed

(0)

StefanOlson
StefanO...

Member

Member

260 points

138 Posts

How do I set the page title?

In my navigation-based Silverlight application I need to be able to set the title of the page. Unfortunately, if I attempt to set it in OnNavigatedTo, it appears to be too late.

Where can I set it within the page class so that I can set it in time?

Secondly there's the scenario where you've using the.net RIA services where you have to wait until the service returns back the information that you need, how do we get the page title set correctly in that situation?

...Stefan

http://www.olsonsoft.com/blogs/stefanolson

SharpGIS
SharpGIS

Contributor

Contributor

4359 points

755 Posts

Re: How do I set the page title?

if(HtmlPage.IsEnabled)
    HtmlPage.Document.SetProperty("title", "My page title");

--
/Morten | blog - twitter
Please click on "Mark as Answer" if this answered your question.

StefanOlson
StefanO...

Member

Member

260 points

138 Posts

Re: How do I set the page title?

There are a couple of problems with the approach of using the Html document, firstly it won't get set in the history unless it is done in time, which is the same problem of setting Page.Title directly Secondly, as I understand itm these properties are not available in the off-line mode.

Really the key issue is how do I set the title consistently early enough to be able to be used in the history.  The current design doesn't seem to even recognize that is important.

...Stefan

http://www.olsonsoft.com/blogs/stefanolson

SharpGIS
SharpGIS

Contributor

Contributor

4359 points

755 Posts

Re: Re: How do I set the page title?

You will have to set it when the page loads then, outside Silverlight.

--
/Morten | blog - twitter
Please click on "Mark as Answer" if this answered your question.

AustinLamb
AustinLamb

Member

Member

602 points

104 Posts

Microsoft
Answered Question

Re: Re: How do I set the page title?

We have fixed this bug post-Beta, so at RTW setting the Title at any time will update the browser's title.

This has one caveat - if you hit the dropdown arrow next to the back button in Firefox (and I think in Chrome or Safari as well, I don't recall right now) you'll see titles get out of sync in there if you hit back/forward.  This is similar to what AJAX experiences (try it in GMail, you'll see it there too).  But we felt this oddity was acceptable given that users see these titles much less often than the main browser window itself.

  • Unanswered Question
  • Answered Question
  • Announcement