Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 例外验证规则不适用';不要对例外情况作出反应_Wpf_Debugging_Validation_Exception - Fatal编程技术网

Wpf 例外验证规则不适用';不要对例外情况作出反应

Wpf 例外验证规则不适用';不要对例外情况作出反应,wpf,debugging,validation,exception,Wpf,Debugging,Validation,Exception,我的文本框上有一个例外验证规则: <Window.Resources> <Style x:Key="textStyleTextBox" TargetType="TextBox"> <Style.Triggers> <Trigger Property="Validation.HasError" Value="true"> <Setter Property="Tool

我的文本框上有一个
例外验证规则

<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}" />
DEBUG
模式下,应用程序崩溃,出现未经处理的异常
“LOL这是一个错误”
(WPF绑定引擎没有捕捉到这一点,我认为它应该…)

RELEASE
模式下,一切正常


谁能告诉我,这到底是为什么?我该如何解决这个问题呢?

解决方案不是很明显,也没有很好的文档记录,但足够简单。 VisualStudio在调试模式下运行时因异常而中断的原因是,它是以这种方式配置的


在调试菜单中,选择“异常…”。在此对话框中,您可以控制VS处理异常的方式。只需取消选中“用户未处理”有关“公共语言运行时异常”,请按“确定”,然后再次运行您的项目。

您是否附加了未处理的异常事件?非常感谢。我一直在为同样的问题伤脑筋。多谢了,那么会发生什么呢?一个异常被触发了,WPF并没有很好地捕捉到它。那么调试器还能工作吗?
private int myProperty;

public int MyProperty
{
    get { return myProperty; }
    set
    {
        if(value > 10)
            throw new ArgumentException("LOL that's an error");
        myProperty = value;
    }
}