This rule is Obsolete | |
Synopsis: | Do let custom value converters return DependencyProperty.UnsetValue instead of null |
Language: | XAML |
Severity Level: | 1 |
Category: | Value Converters |
Description: |
Converters are a concept provided by WPF to facilitate the binding of otherwise incompatible types. If you want to bind two incompatible types, you need a piece of code in between that converts the value from the source type to the target type and, optionally, back. This piece of code is concentrated in a value converter. Because value converters should in principle only be used in bindings, special care should be taken that they do not upset the WPF binding engine. This implies that your custom converter's implementation of the IValueConverter.Convert method should not return values like null or String.Empty to indicate that conversion is not possible, but rather should return DependencyProperty.UnsetValue.
✘
✔ |