What is best practise for IValueConverter?

前端 未结 3 801
萌比男神i
萌比男神i 2021-01-02 17:14
  • What is best practise for IValueConverter?
  • Is it ok to put Exception in Convert method or should it return \"something\"?
3条回答
  •  自闭症患者
    2021-01-02 18:02

    If you fail to convert (malformed values, types, ...), return DependencyProperty.UnsetValue.

    It indicates that the converter produced no value and that the binding uses the FallbackValue, if available, or the default value instead.

    Also, you should convert data with culture-specific conversion or invariant conversions to be on the safe side.

提交回复
热议问题