Search code examples
wpfxamlbindingdefault

Default value at design time XAML


I have a binded TextBlock, XAML:

<TextBlock Text="{Binding MyText}"/>

I know the FallbackValue can be used if the Binding isn't available, but this happens at run time ? Is there any way to show a default value at design time ? It would make things easier if I could see a value when designing my windows instead of an empty TextBlock.

Thanks


Solution

  • Update: Visual Studio 2019 v16.7

    You can now do:

    <TextBlock Text="{Binding MyText}" d:Text="Design time value"/>
    

    If you would prefer a less verbose version of Ian Bamforth's answer, you can just do

    <TextBlock Text="{Binding MyText, FallbackValue=None}"/>