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
  • 4,491
  • 3
  • 35
  • 49
  • [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>
wonea
  • 4,783
  • 17
  • 86
  • 139
pushpraj
  • 13,458
  • 3
  • 33
  • 50
1

You also assign the default value to name of its viewmodel.cs file in its constructor

wonea
  • 4,783
  • 17
  • 86
  • 139
A. S. Mahadik
  • 585
  • 1
  • 5
  • 17
  • 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