This project is read-only.

Design time support

Jun 28, 2013 at 4:50 PM
I having problems getting StyleMvvm design time support to work. I even tested your SimpleWeather application,, but did get it to work.
Are there some more information to read?

Are there some bootstrapping to do,, othervise I dont understand how your IOC container are set up ?
Jun 28, 2013 at 5:23 PM
Hi Lg,

I'm a little surprised that the design time support wasn't working in the SimpleWeather app. I'll take a look this evening or tomorrow and get back to you about that.

As for the IOC setup all the configuration is done in your App.xaml.cs file during run time. At design time it's a little trickier because VS doesn't run your App.xaml, so that where the special design time resource class comes into play.

For some more information on the DI container you can check out this blog post about it. http://stylemvvm.wordpress.com/2013/05/27/dependency-injection-container/

Are there any specific topics you are looking for that I could explain or just more general how does it work?

-Ian
Jun 28, 2013 at 6:10 PM
What is "special design time resource class" ?
Jun 28, 2013 at 6:23 PM
The short answer is when you create a new project a DesignTimeResource class is added to your project and added to the App.xaml file. It helps the bootstrapper find your assembly during design time.

The long answer is because Visual Studio doesn't load any extra assemblies into the process space at design time (not even the assembly for the view you are editing). This makes it impossible to discover ViewModels at design time. To help alleviate the situation I create a small dummy class in the main assembly of your project, at design time the App.xaml is loaded, specifically the design time resource class is instantiated. Using the design time resource I'm able to scan your main assembly for exports.

All this is specific to WinRT, in WPF Visual Studio is greedy and loads all your project assemblies and I'm able to design time support with no hassles. Like most things in WinRT it looks like .Net but it's really not.

Some days I like WinRT ... Some days it feels like they made every decision with the intention of breaking .Net compatibility ...
Jun 28, 2013 at 7:18 PM
So..
If I have created the project manually the DesignTimeResource is not added to the App.xaml file???
If so,, how do I add it manually?
Jun 28, 2013 at 7:26 PM
There isn't anything special about the class, the one that gets created is simply a dummy class. The special sauce is in the key name you use when you put it in the App.xaml

This is the line that is added to the App.xaml
     <Common:DesignTimeResource x:Key="DesignTimeResource"/>
and this is the class file definition
public class DesignTimeResource
{

}

Jun 29, 2013 at 12:17 AM
Hi Lg,

I grabbed the source for simple weather and built it and design time data is working. I'm curious why you aren't seeing the same result.

Let's connect over email and see if we can get this squared away.

-Ian