open System open System.Windows open System.Windows.Input open System.Windows.Interactivity type EventToCommand() = inherit TriggerAction() [] static val mutable private CommandProperty:DependencyProperty [] static val mutable private CommandParameterProperty:DependencyProperty /// Set the command dependency property static do EventToCommand.CommandProperty <- DependencyProperty.Register("Command", typeof, typeof) /// Set the command parameter dependency property static do EventToCommand.CommandParameterProperty <- DependencyProperty.Register("CommandParameter", typeof, typeof) /// Get/Set the Command member this.Command with get() = this.GetValue EventToCommand.CommandProperty :?> ICommand and set value = this.SetValue(EventToCommand.CommandProperty, value) /// Get/Set the CommandParameter member this.CommandParameter with get() = this.GetValue EventToCommand.CommandParameterProperty and set value = this.SetValue(EventToCommand.CommandParameterProperty, value) /// Implement the Invoke method from TriggerAction to execute the command override this.Invoke parameter = let command = this.Command let commandParameter = match this.CommandParameter with | null -> parameter | commandParam -> commandParam if command <> null && command.CanExecute(commandParameter) then command.Execute(commandParameter)