All blog posts with a title that starts with [MVVMbasics] are related to the MVVMbasics framework. If you are only interested in my regular blog posts and not in MVVMbasics, ignore these. To list all articles covering MVVMbasics, go to http://mvvmbasics.mobilemotion.eu/documentation!
Together with version 2.4 of the MVVMbasics framework, new project templates have been published to help you get started with an MVVM app project in Visual Studio. MVVMbasics Templates gives an overview of how to install and use these project templates. The following blog post summarizes the changes compared to the old project templates (which are still available for older versions of Visual Studio).
The new project template installer is only compatible with Visual Studio 2017. Therefore, the old version of the template installer is still available for older versions of Visual Studio, however it contains the old project templates which still reference MVVMbasics 2.3.1. When using these, you must update the references to the MVVMbasics framework using NuGet client (but only if you use UWP, WPF, and Xamarin.Forms projects only, since MVVMbasics 2.4 does not support WinRT and Windows Phone any more).
The new project templates are available on Visual Studio Marketplace, but have been published as a new package in addition to the old template installer, so that both version live side by side. This means:
- Within Visual Studio, regardless of the version, it is possible to download the template installer by searching for “MVVMbasics” in the Extensions and Updates wizard. Doing so in Visual Studio 2017 will download the new installer, in Visual Studio 2012 / 2013 / 2015 will download the old version.
- To download the template installer through a web browser, use the new resource link: https://marketplace.visualstudio.com/items?itemName=mobilemotioneu.MVVMbasicsProjectTemplates2017
Instead of a Visual Studio Extension .vsix file, the new template installer is packaged as .msi installer. This means that it might ask for administrator credentials during installation, however all it actually does is copy the project templates to Visual Studio’s templates folder. In addition, it provides an uninstall option that removes the project templates from Visual Studio.
Template project structure:
Unlike earlier versions, only one project template entry will be created in Visual Studio’s New Project window, which is called MVVMbasics Multi-Platform Application. Choosing this template as base of a new project creates a solution containing 6 projects:
- A base library called MvvmApp.Core that is referenced by all the other projects,
- a Universal Windows app project called MvvmApp.UWP,
- a WPF desktop app project called MvvmApp.WPF,
- a Xamarin.Forms base library called MvvmApp.XamarinForms that is referenced by the Android and iOS app projects,
- an Android app project called MvvmApp.XamarinForms.Android, and
- an iOS app project called MvvmApp.XamarinForms.iOS.
Note that, depending on the frameworks and platforms installed on your machine, Visual Studio may not be able to create all of these projects (the three Xamarin.Forms projects, for example, require the Xamarin SDK being installed), so the actual amount of projects available might differ.
First steps with the new project:
After creating an MVVM app solution using the MVVMbasics Multi-Platform Application project template, follow these steps to adapt the sample code to your need:
- Remove those projects from the solution that represent platforms you don’t want to target.
- Open all projects’ properties and change default namespaces and assembly according to your needs.
- Adapt the app projects’ manifest files and change display names, description and organization / author fields etc. to match your expectations.
- Search for the code lines marked as //TODO as these guide you through the necessary steps to finalize project set up.