views:

32

answers:

2

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?

A: 

Try setting:

<param name="windowless" value="true"/>

<object id="SilverlightControlApp" data="data:application/x-silverlight-2," type="application/x-silverlight-2"
            width="100%" height="100%">
            <param name="source" value="ClientBin/MyTestApp.Client.xap" />
            <param name="onError" value="onSilverlightError" />
            <param name="background" value="white" />
            <param name="minRuntimeVersion" value="4.0.50826.0" />
             <param name="windowless" value="true"/>
          <%--  <param name="minRuntimeVersion" value="3.0.40818.0" />--%>
            <param name="autoUpgrade" value="true" />
             <a href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;amp;v=4.0.50826.0" style="text-decoration: none">
                <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight"
                    style="border-style: none" />
           <%-- <a href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;v=3.0.40818.0" style="text-decoration: none">
                <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight"
                    style="border-style: none" />--%>
            </a>
        </object>
gmcalab
@gmcalab Can you explain further? I have also tried <param name="enablehtmlaccess" value="true"/> without success.
Lucas B
Thanks for more context, but unfortunately it still throws the bridge exception.
Lucas B
A: 

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

Look here and here for examples.

Lucas B