在Silverlight 4中编辑标题 [英] Edit Title in Silverlight 4
问题描述
我们正在开发一个浏览器外的Silverlight 4应用程序,并希望在应用程序加载后更改标题。
示例:
public partial class MainPage:UserControl
{
public MainPage()
{
InitializeComponent
this.Loaded + = new RoutedEventHandler(MainPage_Loaded);
}
public string UserName {get;组; }
public string VersionNumber {get;组; }
void MainPage_Loaded(object sender,RoutedEventArgs e)
{
string title = string.Format(MyApplication {0} {1},this.VersionNumber,this。用户名);
HtmlPage.Window.Eval(string.Format(document.title ='{0}',title));
}
}
strong>
-
上述示例不起作用,并抛出InvalidOperationExceptionDOM /脚本桥被禁用。我找到的所有参考资料,示例
-
调整OutOfBrowserSettings.xml文件,但它不会
有关如何调整标题的任何建议应用程序加载完成后
不幸的是,唯一的方法是创建一个自定义OOB窗口: out-of-browser-window-in-silverlight-4.aspxrel =nofollow>此处和此处示例。
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:
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.
Create a custom OOB Window, example, but I would prefer a more elegant solution.
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.
这篇关于在Silverlight 4中编辑标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!