This project has moved. For the latest updates, please go here.

Registering a View Model

Registering a view model for management by the Jounce framework is as simple as exporting it using the "ExportAsViewModel" tag.

You may tag your view model any way you like. If you prefer a more strongly-typed method, export it using a constant:

public class MyViewModel : BaseViewModel

You can also export based on type. If you export based on type, the tag will be the full type name. For example, a view model in project "MyProject" and namespace "MyProject.ViewModels" called "MyViewModel" will have a tag of "MyProject.ViewModels.MyViewModel" if it is exported like this:

public class MyViewModel : BaseViewModel

This must be done to locate view models and bind view models to views.

At runtime, you can also find out what views have been routed for the view model via the Router (IViewModelRouter) property provided in the base view model class. To get a list of tags, call:

string[] tags = Router.GetViewTagsForViewModel("MyViewModelTag"); 

Then, you can grab the view metadata this way:

IExportAsViewMetadata metadata = GetMetaDataForView(tags[0]); 

Last edited Mar 27, 2011 at 7:59 PM by jeremylikness, version 6


AhmadElBanna Jul 17, 2011 at 9:30 PM 
After This What may cause that the ViewModel is never initialized
I Did it all Like this instruction but It works with the MainViewModel
But Not my ViewModel