只是想知道在实现没有有意义的 ConvertBack 实现(或仅用作 OneWay 的 IValueConverter 实现)时,人们认为最佳实践是什么?
如果它抛出(在那种情况下是什么异常),返回 null 或返回一些默认值。
想法?
最佳答案
IValueConverter.ConvertBack
的文档建议返回 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.
关于wpf - 不实现 IValueConvert.ConvertBack 时的最佳实践,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/265515/