5

I have a Label defined in XAML as follows:

<Label Content="{Binding Name}"></Label>

The problem is that the label is invisible in the XAML editor and I'd like it to have a default value there so that the editor accurately reflects what will show up at runtime.

Is there a way to give it a value in XAML which will show up in the editor, but then use the binding at runtime?

Victor Chelaru
  • 3,818
  • 2
  • 29
  • 41
  • [What approaches are available to dummy design-time data in WPF?](http://stackoverflow.com/questions/1889966/what-approaches-are-available-to-dummy-design-time-data-in-wpf) – har07 Jul 03 '14 at 03:25
  • possible duplicate of [Default value at design time XAML](http://stackoverflow.com/questions/17208665/default-value-at-design-time-xaml) – Mike Hixson Jul 03 '14 at 03:33

2 Answers2

11

here you go

FallbackValue is the answer for the same

example

<Label Content="{Binding Name, FallbackValue=Default}"></Label>
pushpraj
  • 13,153
  • 3
  • 30
  • 49
1

you also assign the default value to name of its viewmode.cs file in its constructor

A. S. Mahadik
  • 565
  • 1
  • 4
  • 14
  • He's right, but he explain badly. He want to say that a default value can be set in the default constructor of the ViewModel, and it will be shown in the design mode. – Xaruth Jul 03 '14 at 08:47