Binding.FallbackValue Property

Definition

Gets or sets the value to use when the binding is unable to return a value.

public:
 property Platform::Object ^ FallbackValue { Platform::Object ^ get(); void set(Platform::Object ^ value); };
IInspectable FallbackValue();

void FallbackValue(IInspectable value);
public object FallbackValue { get; set; }
var object = binding.fallbackValue;
binding.fallbackValue = object;
Public Property FallbackValue As Object
<Binding FallbackValue="fallbackValue" />
- or -
<Binding>
  <Binding.FallbackValue>
    fallbackValue
    </Binding.FallbackValue>
</Binding>

Property Value

Object

Platform::Object

IInspectable

The value to use when the binding is unable to return a value.

Remarks

Usually you specify FallbackValue for bindings that display strings in UI. For this case the FallbackValue is also a string. You might want to use a resource so that it's easier to localize this string.

If you do specify a literal string for FallbackValue, you must use alternate quotes for the FallbackValue value within the {Binding} markup extension usage if your string contains spaces, because the {Binding} markup extension usage for an attribute is already within quotes. For example, <object property="{Binding FallbackValue='A literal string'}" />.

If used within a {Binding} markup extension usage, the value for FallbackValue can use any implicit string conversions that are already available to XAML, such as treating 0 as a string for a string binding, or converting enum values. For example, <object property="{Binding Path=Visibility, FallbackValue=Collapsed}" /> is valid because the parser can evaluate the string "Collapsed" and return Visibility.Collapsed as the fallback for a Visibility value.

TargetNullValue is a similar property with similar scenarios. The difference is that a binding uses FallbackValue for cases where the Path doesn't evaluate on the data source at all, or if attempting to set it on the source with a two-way binding throws an exception that's caught by the data binding engine. FallbackValue is also used if the source value is the dependency property sentinel value DependencyProperty.UnsetValue. A binding uses TargetNullValue if the Path and Source do evaluate, but the value found there is null.

You can't set the property values of a Binding object after that binding has been attached to a target element and target property. If you attempt this you'll get a run-time exception.

Applies to

See also