开发者

Edit Title in Silverlight 4

开发者 https://www.devze.com 2023-01-22 03:15 出处:网络
We are developing an out-of-browser Silverlight 4 application and want to change the title after the application loads.

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()
    {
        InitializeCompone开发者_JS百科nt();
        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?


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

Look here and here for examples.


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;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&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>
0

精彩评论

暂无评论...
验证码 换一张
取 消