代码之家  ›  专栏  ›  技术社区  ›  Lucas B

在Silverlight 4中编辑标题

  •  2
  • Lucas B  · 技术社区  · 15 年前

    我们正在开发浏览器外的Silverlight4应用程序,希望在加载应用程序后更改标题。

    例子:

    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));
        }
    }
    

    我试过三件事:

    1. 上面的示例不起作用,并引发一个InvalidOperationException“dom/scripting bridge is disabled.”我找到的所有引用, example 表示HTML桥在OOB模式下被禁用。

    2. 创建自定义OOB窗口, example 但我更喜欢更优雅的解决方案。

    3. 调整outofbrowsersettings.xml文件,但加载后似乎无法访问它。

    关于如何在应用程序加载后调整标题有什么想法吗?

    2 回复  |  直到 15 年前
        1
  •  2
  •   Lucas B    15 年前
        2
  •  0
  •   Gabe    15 年前

    <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>
    
    推荐文章