This project is read-only.

Sundstrom MVVM is a lightweight MVVM Framework.

Consisting of:

  • ViewModelBase class (implements INotifyPropertyChanged),
    • ExtendedViewModelBase (with validation)
  • Commands
    • RelayCommand, RelayCommand<T>
    • AsyncRelayCommand, AsyncRelayCommand<T> (for Unit Testing)
  • MessageBus

Everything is in a project targeting Portable Class Library (PCL) for portability.

The framework can thus be used in any modern .NET-based app project; Windows Store apps, Windows Phone 8, Xamarin.iOS, and Xamarin.Android. WPF is of course also supported.

There is also a version targeting .NET Framework 4.0.3. (for use on Windows XP)

Recommending NuIoc for dependency injection.

Getting started

  1. Get the lastest NuGet-package from our public feed: https://www.myget.org/F/robert-sundstroms-feed/
    PM> Install-Package Sundstrom.Mvvm
  2. Create a class for your View Model that inherits ViewModelBase.

    (Defining an interface for your View Model is good practice. It later helps when doing dependency injection.)
    /// <summary>
    /// Sample ViewModel.
    /// </summary>
    public sealed class MainViewModel : ViewModelBaseIMainViewModel
    {
        private string _sampleProperty;
 
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dialogService">Injected IDialogService.</param>
        public MainViewModel(IDialogService dialogService)
        {
            DialogService = dialogService;
 
            SampleProperty = "Hello World!";
 
            // Use RelayCommand for SampleCommand.
            SampleCommand = new AsyncRelayCommand<string>(SampleCommandImpl);
        }
 
        public IDialogService DialogService { getset; }
 
        /// <summary>
        /// SampleProperty
        /// </summary>
        public string SampleProperty
        {
            get { return _sampleProperty; }
            set
            {
                _sampleProperty = value;
                RaisePropertyChanged();
            }
        }
 
        /// <summary>
        /// SampleCommand
        /// </summary>
        public ICommand SampleCommand { getprivate set; }
 
        /// <summary>
        /// Implementation of SampleCommand.
        /// </summary>
        /// <param name="message"></param>
        private async Task SampleCommandImpl(string message)
        {
            // Call the DialogService asynchronously.
            await DialogService.ShowDialogAsync(message);
        }
    }

 

Last edited Aug 16, 2014 at 11:22 AM by RobertSundstrom, version 19