Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a DesignInstance in XAML

Tags:

c#

mvvm

xaml

I actually learn the MVVM-Pattern and I found in a Tutorial this:

d:DataContext="{d:DesignInstance step1:ViewModel}">

I know that I use the Data Context to bind Data but what I don´t understand is for what the DesignInstance is usefull and why I write it down there ?

On the MSDN HP stands: "DesignInstance is a design-time property." But I can´t do anything with that do.

Edit: The Tutorial Step 1 from http://www.learnmvvm.com/tutorial.html#step1-1

like image 390
FoldFence Avatar asked Feb 29 '16 09:02

FoldFence


1 Answers

The design instance is used when the view is opened in the visual studio editor.

Say you have a view that uses a list view to display a list of products, and you use a template to display each product. Without a viewmodel, your view will not display anything, and you can't really see what the view will look like in the application.

You don't want to run your entire app, with all its dependencies from the editor. Instead supply a design instance, with some stub data that makes the view render some products. Think of it as some fake test data that makes your view render correctly in the editor.

like image 96
Mikael Nitell Avatar answered Sep 28 '22 13:09

Mikael Nitell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!