- To use this sample, instsall the Xamarin tools for Visual Studio 2015.
- See here for details:
- To overcome 2GB RAM limit see:
- Using ReSharper from JetBrains will provide XAML intellisense for Xamarin Forms
- To unlock the Android emulator, drag the lock icon on the screen upwards:
- Create a new Cross-Platform project using Visual Studio 2015 or higher
- Target Framework: Xamarin.Forms Portable
- Update NuGet packages
- Build the solution
-
Add the SimpleMvvmToolkit.Express NuGet package to each project
-
Use Code Snippets Manager to add the Simple Mvvm C# code snippets
-
Add Models folder
- Add Customer class
- Use mvvmprop snippet to add properties
- CustomerId, CustomerName, City
- Add Services folder
- Interface: ICustomerService
- Class: MockCustomerService
- Add ViewModels folder
- MainPageViewModel
- CustomerViewModel
- Add Locators folder
- Add NuGet package: SimpleInjector
- Add ViewModelLocator class
- Add ViewModelLocator to app resources
- Remove existing App.cs file
- Add new Forms Xaml Page named App.cs
- Replace ContentPage with Application
- Add a Resource for ViewModelLocator with the key "Locator"
<?xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:locators="clr-namespace:SimpleMvvmSamples.XamarinForms.Locators;assembly=SimpleMvvmSamples.XamarinForms"
x:Class="SimpleMvvmSamples.XamarinForms.App">
<Application.Resources>
<ResourceDictionary>
<locators:ViewModelLocator x:Key="Locator"/>
</ResourceDictionary>
</Application.Resources>
</Application>
- Add Views folder
- Add Forms Xaml Page: CustomerView
- Add StackLayout with a BindingContext of MainPageViewModel
- Add a Grid within the StackLayout with a BindingContext of CustomerViewModel
- Build and deploy each target project
- Clicking the New Customer button should populate the Entry controls