Skip to main content

Posts

Showing posts with the label TargetNullValue

FallbackValue and TargetNullValue

One of the ability of binding in WPF is the ability to support Fallback values. Fallback values are used when a binding comes up with an un-appropriate value which in turn can't be set on binding target. There are 2 types of Fallback values:        TargetNullValue :     As its name communicate itself that when a source object’s property is null, then what is the alternate value you want to set for the target. So, whatever value is set for TargetNullValue, it will be set for target. Pretty simple, isn't it ? 2   FallbackValue :      This is used when a binding cannot come up with a value at all, based on the the data source and the path. Or in other words, FallbackValue is used when the property binded with source is not at all available. In that case, value supplied to FallbackValue will be considered at the target end. Getting into the code:  Now, let’s jump on to the code on how to use both of these. Here aim is to bind the given text box with EmployeeName