Skip to content

Instantly share code, notes, and snippets.

@dmohl
Created December 1, 2014 03:14
Show Gist options
  • Save dmohl/01d1448a902f2c6d83cc to your computer and use it in GitHub Desktop.
Save dmohl/01d1448a902f2c6d83cc to your computer and use it in GitHub Desktop.
FsXaml ViewModel
namespace ViewModels
open System
open System.Windows
open FSharp.ViewModule
open FSharp.ViewModule.Validation
open FsXaml
type MainView = XAML<"MainWindow.xaml", true>
type MainViewModel() as self =
inherit ViewModelBase()
let name = self.Factory.Backing(<@ self.Name @>, "")
let display = self.Factory.Backing(<@ self.Display @>, "")
let goCommand = self.Factory.CommandSyncParam(fun param -> self.Display <- sprintf "Your Name Is: %s" param)
member x.Name with get() = name.Value and set value = name.Value <- value
member x.Display with get() = display.Value and set value = display.Value <- value
member x.GoCommand = goCommand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment