7

I already know about the Binding.DoNothing that one can return from an IValueConverter implementation to signify that no other operation should take place.

However, I cannot find a reference, or documentation nicely summing out, what the other special values are - such as returning the fallback value. What are they?

Jean Hominal
  • 16,518
  • 5
  • 56
  • 90
  • Fallback happens if the binding does not work in the first place or possibly if some exception is thrown when binding. – H.B. Apr 30 '12 at 13:37
  • the best way to know about such values is to read articles about [Binding](http://msdn.microsoft.com/en-us/library/ms617928.aspx) and [BindingBase](http://msdn.microsoft.com/en-us/library/ms618281.aspx) classes. Everything you can use is listed there – koshdim Apr 30 '12 at 14:16

1 Answers1

16

Binding.DoNothing is an object instance that you actively return from a value converter; it instructs the binding engine to not update the value of the target property at all. Here's a nice example by Josh Smith of what you might use this for.

FallbackValue is a property that you set on bindings; it allows you to specify the value to be applied to the target property if:

  • the binding source cannot be resolved (e.g. wrong binding path), or
  • the binding property value is equal to DependencyProperty.UnsetValue, or
  • a value converter used for the binding throws an exception, or
  • a value converter used for the binding returns DependencyProperty.UnsetValue, or
  • the value produced by the binding pipeline is not valid for the target property (e.g. wrong type)

TargetNullValue is also a property you set on bindings; it allows you to specify the value to be applied to the target property if the value of the source property is null. For example, if you bind a text box to a string property TargetNullValue lets you pick what appears in the text box if the source string is null.

Jon
  • 428,835
  • 81
  • 738
  • 806