I encountered a very annoying change for me from .NET3.5 to .NET4.0. When using a ExceptionValidationRule on a binding for validating the exception thrown in the bound properties setter gets handled by the binding in 3.5. In 4.0 it is thrown as unhandled while debugging.
Changing the target framework from 3.5->4.0 in this small example (new WPF Application project) shows the problem:
MainWindow.xaml.cs:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.DataContext = this;
}
private string _field = "Test";
public string Property
{
get { return _field; }
set
{
if (value.Length < 4)
_field = value;
else
throw new ArgumentException();
}
}
}
MainWindow.xaml
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow"
Height="350"
Width="525">
<TextBox Width="300"
Height="100"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Text="{Binding Property, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
</Window>
Is it possible to have these exceptions handled at debug time in .NET4.0?