Search code examples
silverlight-4.0c#-4.0silverlight-oob

Edit Title in Silverlight 4


We are developing an out-of-browser Silverlight 4 application and want to change the title after the application loads.

Example:

public partial class MainPage : UserControl
{
    public MainPage()
    {
        InitializeComponent();
        this.Loaded += new RoutedEventHandler(MainPage_Loaded);
    }

    public string UserName { get; set; }
    public string VersionNumber { get; set; }

    void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        string title = string.Format("MyApplication {0} {1} ", this.VersionNumber, this.UserName);

        HtmlPage.Window.Eval(string.Format("document.title='{0}'", title));
    }
}

Three things I have tried:

  1. The above example does not work and throws an InvalidOperationException "The DOM/scripting bridge is disabled." All the references I found, example, said the HTML bridge is disabled in OOB mode.

  2. Create a custom OOB Window, example, but I would prefer a more elegant solution.

  3. Adjust the OutOfBrowserSettings.xml file, but it doesn't appear that I can get access to it after Load.

Any ideas on how to adjust the title after the application has loaded?


Solution

  • Unfortunately, the only way to do this is to create a custom OOB Window:

    Look here and here for examples.