vs2010+silverlight4 error

在用vs2010作silverlight4 的时候,查看设计页面出现下面问题,不知各位大仙怎么解决此问题的,谢谢。

[HtmlPage_NotEnabled]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=8.0.50401.0&File=System.Windows.Browser.dll&Key=HtmlPage_NotEnabled
   at System.Windows.Browser.HtmlPage.VerifyThreadAndEnabled()
   at System.Windows.Browser.HtmlPage.get_Document()

 

如图所示 :

 

google之后,才知道出错原因是用了htmlPage这个类,然后就发现了另一个东东System.ComponentModel.DesignerProperties,试试管用,好了还是赶紧分享给大家的好:

 

 

private void UserControl_Loaded(object sender, RoutedEventArgs e)

{

    // Did the QueryString contain an Email address?

    if (HtmlPage.Document.QueryString.Keys.Contains("Email") )//此外为出错的地方

        txtEmailTo.Text = HtmlPage.Document.QueryString["Email"].ToString();

}

 

Luckily, there is a special class, System.ComponentModel.DesignerProperties, which allows us to check at runtime whether we are in Design Mode or not. We can just add a check on this, and if we are in Design Mode, we get out of the Loaded event handler:

 

private void UserControl_Loaded(object sender, RoutedEventArgs e)

{

    if (DesignerProperties.GetIsInDesignMode(this))// 在出错前加上这句判断和return语句,就ok 了

        return;

 

    // Did the QueryString contain an Email address?

    if (HtmlPage.Document.QueryString.Keys.Contains("Email") )

        txtEmailTo.Text = HtmlPage.Document.QueryString["Email"].ToString();

}

此解决方法原文地址:http://www.andybeaulieu.com/Home/tabid/67/EntryID/158/Default.aspx

这个地址中的:Blend Artboard Exceptions and Loaded Event 文章

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值