WPF DataBinding Default Value (TargetNullValue)

<TextBlock Text={Binding MyStringProperty, TargetNullValue='' FallbackValue='' />

If the MyStringProperty is null, the binding will throw an exception in absence of the "TargetNullValue". If the databound property is null, the value specified in the TargetNullValue (e.g. "" in this case) will be used

Comments

Popular posts from this blog

WPF How to Dispose ViewModel when the associated UserControl (Not Window) closes?

WPF: VisualTreeHelper Find Parent of Specific Type

C# How to unit test Dispatcher