Best practice when not implementing IValueConvert.ConvertBack

前端 未结 4 1579
难免孤独
难免孤独 2020-12-30 19:24

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

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-30 20:22

    The documentation for IValueConverter.ConvertBack recommends 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.

提交回复
热议问题