gpt4 book ai didi

wpf - 不实现 IValueConvert.ConvertBack 时的最佳实践

转载 作者:行者123 更新时间:2023-12-03 08:37:20 27 4
gpt4 key购买 nike

只是想知道在实现没有有意义的 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com