Advertisement
Guest User

DelegateCommand f#

a guest
Mar 5th, 2011
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.40 KB | None | 0 0
  1. type DelegateCommand<a>(execute : 'a -> unit, ?canExecute : 'a  ->  bool) =
  2.   let event = Event<_,_>()
  3.   interface ICommand with
  4.     member this.CanExecute(param : obj) =
  5.       if canExecute.IsSome then
  6.         canExecute.Value(param :> 'a)
  7.      else true
  8.    member this.Execute (param : obj) =
  9.      execute(param :> 'a)
  10.     [< CLIEvent >]
  11.     member this.CanExecuteChanged =
  12.       event.Publish
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement