Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellabyte/1524382 to your computer and use it in GitHub Desktop.
Save kellabyte/1524382 to your computer and use it in GitHub Desktop.
public TViewModel ViewModel
{
get
{
TViewModel viewModel;
bool designMode = DetectDesignMode();
if (designMode)
{
// At design time instantiate design time version.
// This populates mock data, dependencies don't have to be real.
viewModel = new TDesignViewModel();
}
else
{
// Request IoC container to resolve view model & its deps.
viewModel =
ApplicationHost.Current.Container.Resolve<TViewModel>();
}
viewModel.OnLocated(wasCreated);
return viewModel;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment