Skip to main content
Microsoft Silverlight
Home Forums General Silverlight New Features in Silverlight 3 How do I set the page title?
4 replies. Latest Post by AustinLamb on June 4, 2009.
(0)
StefanO...
Member
260 points
138 Posts
05-30-2009 1:23 AM |
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
SharpGIS
Contributor
4359 points
755 Posts
05-31-2009 11:55 PM |
if(HtmlPage.IsEnabled) HtmlPage.Document.SetProperty("title", "My page title");
06-03-2009 1:25 AM |
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.
06-03-2009 2:27 AM |
You will have to set it when the page loads then, outside Silverlight.
AustinLamb
602 points
104 Posts
06-04-2009 5:51 PM |
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.