How to display placeholder value in WPF Visual Studio Designer until real value can be loaded How to display placeholder value in WPF Visual Studio Designer until real value can be loaded wpf wpf

How to display placeholder value in WPF Visual Studio Designer until real value can be loaded


I often use FallbackValue on the binding to have something to look at while I design user controls. For example:

<TextBlock Text={Binding Path=AverageValue, FallbackValue=99.99} />

However, since FallbackValue is not just applied at design time, this might not be appropriate if you want to use FallbackValue at run time for other reasons.


In your example you might need to use TargetNullValue, not FallbackValue as the binding expression is likely to be null as the DataContext is null at design time.

FallBackValue is used if the Path given in the binding does not exist, but as no path is specified I'd assume the DataContext would then be evaluated as null.

<UserControl ... snip...>  <!-- Bind the textblock to whatever's in the DataContext -->       <TextBlock Text="{Binding TargetNullValue=Nothing to see}"></TextBlock></UserControl>

Also note that .NET Framework 3.5 SP1 is needed as these two additional properties were added in SP1.


I don't know of a way to do this with Visual Studio's editor, but you can do this with Expression Blend.

Here's and article describing how to achieve this.

I do hope that MS merge the functionality of Blend and Visual Studio together because having one package do one thing and another something else is a bit silly. Especially when they're from the same company.