views:

1075

answers:

2

Just wondering what people think is the best practice when implementing an IValueConverter which does not have a meaningfull ConvertBack implementation (or one that is only to be used as OneWay)?

Should it throw (and in that case what exception), return null or return some default value.

Thoughts?

+14  A: 

The MSDN documentation for IValueConverter.ConvertBack recomends returning DependencyProperty.UnsetValue.

The data binding engine does not catch exceptions that are thrown by a user-supplied converter. Any exception that is thrown by the ConvertBack method, or any uncaught exceptions that are thrown by methods that the ConvertBack method calls, are treated as run-time errors. Handle anticipated problems by returning DependencyProperty.UnsetValue.

Todd White
+2  A: 

According Microsoft, you should return DependencyProperty.UnsetValue

Tamir