Another quick post to demonstrate how to create WPF Command classes in F#. Notably, these include a CLR event in the inherited interface that needs to be implemented in F#.
#light open Microsoft.FSharp.Control open System.Windows.Input type MyCustomCommand() = // This is the member field for the event let CanExecuteChangedEvent = new Event<_,_>() interface ICommand with member self.Execute (argument:obj) = () member self.CanExecute (argument:obj) = true [<CLIEvent>] member self.CanExecuteChanged = CanExecuteChangedEvent.Publish
The F# source code for Event is good educational reading for the curious!
- MSDN: ICommand interface reference: http://msdn.microsoft.com/en-us/library/system.windows.input.icommand.aspx
- MSDN: F# Reference on Events: http://msdn.microsoft.com/en-us/library/dd233189(VS.100).aspx