I have a property bound to ComboBox
<ComboBox ItemsSource="{Binding AvailableTypes}"
SelectedValue="{Binding Kind, Mode=TwoWay}}"/>
and in the property setter I throw an exception in some business circumstances to abort setting the property.
public MyKind Kind
{
get { return kind; }
set
{
if (kind != value)
{
if (SomeRuleFailed(value))
throw new Exception("to be ate by binding code");
kind = value;
}
}
}
It works smooth except the fact that VS2010 pops up every time I raise exception. Is there any kind of exception to raise or attribute to be set so debugger left in background?
You should not be throwing an instance of an
Exceptionclass. You should throw an instance of a class derived fromException.You can create your own exception class (and you should out of habit if you have something that’s not already covered by the framework) then you can select the exceptions you want Visual Studio to break on.
Once you’ve created your exception class, go to Debug–>Exceptions… and then pick the exceptions you want to have the debugger break on.