Simple F# ViewModel for Silverlight MVVM

The wonderful F# Snippets community site continues to be a source of great inspiration, guidance and samples in the practical use of F# in all sorts of domains

The latest addition is a "Simple F# ViewModel for Silverlight MVVM". F# is an excellent language for implementing Silverlight View Model components and using them in Expression Blend.

Silverlight default architecture is Model-View-ViewModel. This code gives full design time support for Microsoft Expression Blend. The F# ViewModel is seen as strongly typed data source in the Blend UI. There are two properties binded to the view: HiLabel (OneWay data binding) and MyName (TwoWay data binding). ViewModel implements the INotifyPropertyChanged to support the binding. The view project (HelloApp) is made with Blend (by designers) and it is Silverlight 5.0 project. The view codebehind is c# file and it has only this.DataContext -assignment. The viewmodel project (HelloApp.ViewModel) is F# Silverlight 4.0 library. It is made with VS2010 and F# (by developers). It contains the logical functionality of the current view.

[ followed by the code of course. ]

You can also find some good MVVM guidance in the F# Online Templates on Visual Studio Gallery (In Visual Studio 2010, use New Project -> Online Templates -> search for "fsharp")

don