Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

How do I set the page title? RSS

4 replies

Last post Jun 04, 2009 09:51 PM by AustinLamb

(0)
  • StefanOlson

    StefanOlson

    Member

    260 Points

    139 Posts

    How do I set the page title?

    May 30, 2009 05:23 AM | LINK

    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

    4825 Points

    832 Posts

    Re: How do I set the page title?

    Jun 01, 2009 03:55 AM | LINK

    if(HtmlPage.IsEnabled)
        HtmlPage.Document.SetProperty("title", "My page title");
    --
    /Morten | Silverlight MVP | blog - twitter
    Please click on "Mark as Answer" if this answered your question.
  • StefanOlson

    StefanOlson

    Member

    260 Points

    139 Posts

    Re: How do I set the page title?

    Jun 03, 2009 05:25 AM | LINK

    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

    4825 Points

    832 Posts

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

    Jun 03, 2009 06:27 AM | LINK

    You will have to set it when the page loads then, outside Silverlight.
    --
    /Morten | Silverlight MVP | blog - twitter
    Please click on "Mark as Answer" if this answered your question.
  • AustinLamb

    AustinLamb

    Member

    602 Points

    104 Posts

    Microsoft

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

    Jun 04, 2009 09:51 PM | LINK

    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.