F# and MVVM Light Toolkit Sample Application

MVVM Light Toolkitを使ってViewModelとModelをF#で記述した足し算を行うだけのシンプルなアプリケーションの実装例です。サンプルアプリケーションは以下のような形のものになります。以下に、サンプルに含まれるプロジェクトの概要を示します。 Okazuki.Fsharp.Mvvmプロジェクト(C#)F#でのViewModelの定義を楽にするためのヘルパークラスを定義したViewModelの基本クラスを定義しています。 Okazuki.Fsharp.Mvvm.Sample(C#)MVVM Light Toolkitをベースにしたプ

 
 
 
 
 
(0)
249 times
Add to favorites
6/21/2011
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#, F#
/*
  In App.xaml:
  <Application.Resources>
      <vm:ViewModelLocatorTemplate xmlns:vm="clr-namespace:Okazuki.Fsharp.Mvvm.Sample"
                                   x:Key="Locator" />
  </Application.Resources>
  
  In the View:
  DataContext="{Binding Source={StaticResource Locator}, Path=ViewModelName}"

  You can also use Blend to do all this with the tool's support.
  See http://www.galasoft.ch/mvvm
*/

using GalaSoft.MvvmLight;
using Okazuki.Fsharp.Mvvm.ViewModel;

namespace Okazuki.Fsharp.Mvvm.Sample.ViewModel
{
    /// <summary>
    /// This class contains static references to all the view models in the
    /// application and provides an entry point for the bindings.
    /// </summary>
    public class ViewModelLocator
    {
        private static MainViewModel _main;

        /// <summary>
        /// Initializes a new instance of the ViewModelLocator class.
        /// </summary>
        public ViewModelLocator()
        {
            ////if (ViewModelBase.IsInDesignModeStatic)
            ////{
            ////    // Create design time services and viewmodels
            ////}
            ////else
            ////{
            ////    // Create run time services and view models
            ////}

            _main = new MainViewModel();
        }

        /// <summary>
        /// Gets the Main property which defines the main viewmodel.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
            "CA1822:MarkMembersAsStatic",
            Justification = "This non-static member is needed for data binding purposes.")]
        public MainViewModel Main
        {
            get
            {
                return _main;
            }
        }
    }
}