我在我的文本框有一个ExceptionValidationRule
:ExceptionValidationRule没有反应异常
<Window.Resources>
<Style x:Key="textStyleTextBox" TargetType="TextBox">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<TextBox x:Name="myTextBox"
{Binding Path=MyProperty, ValidatesOnExceptions=True}"
Style="{StaticResource ResourceKey=textStyleTextBox}" />
和MyProperty
看起来像这样:
private int myProperty;
public int MyProperty
{
get { return myProperty; }
set
{
if(value > 10)
throw new ArgumentException("LOL that's an error");
myProperty = value;
}
}
在DEBUG
模式,应用程序崩溃与未处理的异常"LOL that's an error"
(WPF绑定引擎没有抓住这一点,我认为它应该......)。
在RELEASE
模式下,一切工作正常。
有人可以告诉我,为什么地狱这是怎么回事?我该如何解决这个问题?
您是否附加了UnhandledException事件? – Krimson 2010-12-08 14:09:44