Search code examples
silverlightdata-bindingmvvmtextblock

How to supply a design time value for silverlight textblock that is bound to viewmodel property?


I have a TextBlock in my XAML that has its text bound to a property in my viewmodel.

<TextBlock x:Name="SomeText" Text="{Binding TheTextProperty}" />

This works fine, but at design time, there is no viewmodel so the property is unresolvable and the text is blank. This is hard to work with in the designer because it shows no visible text.

How can I specify some default text to use at design time?


Solution

  • Maybe you could try

    <TextBlock x:Name="SomeText" Text="{Binding TheTextProperty, FallbackValue='Some other text'}" />
    

    as documented here.