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.