Winforms 有没有办法使绑定类抛出绑定对象中引发的异常?
考虑以下类别:Winforms 有没有办法使绑定类抛出绑定对象中引发的异常?,winforms,data-binding,swallowed-exceptions,Winforms,Data Binding,Swallowed Exceptions,考虑以下类别: public class Toto { string _Test = "try me!"; public string Test { get { return _Test; } set { throw new Exception("This shouldn't be swallowed."); } } } 现在,将这个对象的Test属性绑定到
public class Toto
{
string _Test = "try me!";
public string Test
{
get { return _Test; }
set { throw new Exception("This shouldn't be swallowed."); }
}
}
现在,将这个对象的Test属性绑定到一个textbox并尝试键入一个值将使该对象抛出一个异常,该异常将被绑定类吞并
我发现处理异常的唯一方法(当然不是在属性设置程序本身中)是使用绑定的BindingComplete事件
有没有什么方法可以设置数据绑定,以便在遇到不可能知道的异常时,它会关心自己的事情?看起来Winform的数据绑定会吞噬异常,就是这样。一个可怕的设计,伊姆霍