当MVVM模式使用绑定Binding,绑定的值无效或者不存在时,想显示的默认值可以设置FallbackValue属性。
MSDN官方解释:Gets or sets the value to use when the binding is unable to return a value
翻译中文:获取或设置绑定无法返回值时要使用的值
例如在TextBlock控件中绑定Text时可以这样使用
Text="{Binding Name,RelativeSource={RelativeSource AncestorType=Window},FallbackValue=张三}"