1

I would like to have values of my database displayed in the datagrid of the xaml designer.

The datagrid has for context a viewModel that queries data in the database.

But the Xaml designer does not have access to my database configuration that is in the app.config.

ConfigurationManager.ConnectionStrings["myDbConnection"] is null.

How to have the visual studio designer to use the default app.config file to have dome real values that appear in the xaml designer ?

EDIT: I want to viewModel instance to be created by the designer so that it does supply some data from the database in the designer.

Anthony Brenelière
  • 60,646
  • 14
  • 46
  • 58

1 Answers1

0

I usually use this approach:

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModel:MyViewModel, IsDesignTimeCreatable=False}"

More info is available here

Community
  • 1
  • 1
isxaker
  • 8,446
  • 12
  • 60
  • 87
  • It's not what I want: I want to viewModel instance to be created by the designer so that it does supply some data from the database in the designer. – Anthony Brenelière Jun 10 '16 at 13:02