Tôi có một ExceptionValidationRule
trên TextBox của tôi:ExceptionValidationRule không phản ứng với trường hợp ngoại lệ
<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}" />
và MyProperty
trông như thế:
private int myProperty;
public int MyProperty
{
get { return myProperty; }
set
{
if(value > 10)
throw new ArgumentException("LOL that's an error");
myProperty = value;
}
}
Trong chế độ DEBUG
, ứng dụng bị treo với ngoại lệ unhandled "LOL that's an error"
(WPF Binding Engine không bắt được điều này và tôi nghĩ nó nên ...).
Ở chế độ RELEASE
, mọi thứ đều hoạt động tốt.
Ai đó có thể cho tôi biết, lý do tại sao địa ngục là điều này xảy ra? Và làm thế nào tôi có thể sửa lỗi này?
Bạn có sự kiện UnhandledException được đính kèm không? – Krimson