怎样才能发现在Silverlight SetBinding sucess还是失败? [英] How does one detect SetBinding sucess or failure in Silverlight?

查看:108
本文介绍了怎样才能发现在Silverlight SetBinding sucess还是失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简单的绑定从C#:

  Binding binding = new Binding(SourceName);
  binding.Mode = BindingMode.TwoWay;
  BindingExpressionBase beb = SetBinding(SourceDependencyProperty, binding);

我想检测SetBinding是否是成功的。显然SetBinding知道什么时候有一个问题,因为它显示在输出窗口跟踪的应用程序运行时:

I would like to detect whether or not the SetBinding was successful. SetBinding obviously knows when it has an issue because it displays in the Output window tracing when the application is running:

System.Windows.Data错误:BindingEx pression路径错误:在Tc.Views.TestAccount...

System.Windows.Data Error: BindingExpression path error: 'InterestRate' property not found on 'Tc.Views.TestAccount' ...

该BindingEx pressionBase看起来是一样的我SetBinding()是成功还是失败,并没有什么异常抛出。我尝试了不同的值的绑定通知的标志以及

The BindingExpressionBase looks the same to me whether SetBinding() succeeds or fails and there is no exception thrown. I tried different values for the binding notification flags as well.

先谢谢了。

推荐答案

我建议你使用卡尔·Shiflett的<一个href=\"http://karlshifflett.word$p$pss.com/2009/06/08/glimpse-for-silverlight-viewing-exceptions-and-binding-errors/\"相对=nofollow>管窥Silverlight的。该GlimpseService暴露了一个API,它会允许你手动处理任何约束力异常。

I suggest you use Karl Shiflett's Glimpse for Silverlight. The GlimpseService exposes an API that'll allow you to handle any binding exceptions manually.

的基本技术是相当简单 - 听Application.UnhandledException和Application.RootVisu​​al.BindingValidationError,你应该能够拦截绑定错误。

The basic technique is fairly simple - listen to Application.UnhandledException and Application.RootVisual.BindingValidationError and you should be able to intercept binding errors.

这篇关于怎样才能发现在Silverlight SetBinding sucess还是失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆