Although it’s really easy and straightforward to set up a Visual Studio project based on the MVVMbasics framework, you don’t need to repeat the necessary steps for each newly created project. Instead, there are template projects available you can build your Apps upon.
In Visual Studio, simply search for “MVVMbasics” within the Extensions and Updates wizard (Tools menu -> Extensions and Updates…), or download and install the MVVMbasics Project Templates from Visual Studio Marketplace for Visual Studio 2017 or for Visual Studio 2015 / 2013 / 2012.
Visual Studio 2017:
After the installation has completed, you’ll find a new project type in Visual Studio’s New Project wizard (File menu -> New -> Project…) within the Visual C# category 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.
After the projects have been created, you can remove those that represent platforms you don’t want to target. Then open all projects’ properties and change namespaces and assembly according to your needs. Adapt the app projects’ manifest files in a similar way. Finally, search for the code lines marked as //TODO as these guide you through the necessary steps to finalize project set up.
Visual Studio 2012 / 2013 / 2015:
(Note that this older version of the Project Templates still references the outdated version MVVMbasics 2.3, but you should be able to update this references simply via NuGet!
After the installation has completed, you’ll find 6 new project types in Visual Studio’s New Project wizard (File menu -> New -> Project…), namely within the Visual C# -> Multi-Platform category. To create an App that is based on MVVMbasics, follow a few simple steps:
- Create a project of type Multi-Platform Application Core using MVVMbasics as a new solution, choose project name and location. This project will include all your Models, Viewmodels, Service interfaces, and Service implementations of all Services that can be implemented in a platform-independent way.
- Right-click the newly created solution in Solution Explorer, choose Add -> New Project…, navigate to the Visual C# -> Multi-Platform category and select one of the additional project called “xxx App for MVVMbasics Core project”, depending on which platform your App shall target. Visual Studio will add a new project of the chosen type and automatically configure the necessary references to the existing core project. This platform-dependent project will include all your Views as well as platform-dependent Service implementations.
- If you want your App to target multiple platforms, simply repeat step 2 for all desired target platforms! All platform-dependent projects added to the solution will automatically be configured to reference the Viewmodels and Models defined within the Core project.
After the projects have been created, search for the code lines marked as //TODO as these guide you through the necessary steps to finalize project set up.