fsprojects / FsXaml

F# Tools for working with XAML Projects
http://fsprojects.github.io/FsXaml/
MIT License
171 stars 48 forks source link

EventToMailbox does not work with MailboxParameter #58

Closed TheJayMann closed 7 years ago

TheJayMann commented 7 years ago

I was trying to use the EventToMailbox trigger so that I could process an item associated with the button in a mailbox. I used databinding to link the MailboxParameter to the DataContext of the current item of the ItemsControl. After wiring everything up, nothing happened on the button click. I noticed every time I clicked the button, debug output would show a System.ArgumentException had occurred. I set the debugger to break on said exception, and I saw the details of the exception was that (paraphrasing) a Tuple<object,bool> cannot be applied to a method which takes a ChildViewModel parameter. I also saw on the call stack FsXaml.Wpf.Blend.dll!FsXaml.EventToMailbox.Invoke(object param), so I looked at the code and found https://github.com/fsprojects/FsXaml/blob/e1278f85fd90ba3ed8b0cfc17238749253362479/src/FsXaml.Wpf.Blend/EventToMailbox.fs#L16-L19. I believe the problem is specifically with the last line, | param -> param :> obj, as this wraps the MailboxParameter with the status of whether to pass EventArgs to the mailbox as a tuple, rather than just the MailboxParameter itself. Rather, the code should either be | param, _ -> param :> obj or | _ -> this.MailboxParameter.

ReedCopsey commented 7 years ago

Thank you, @TheJayMann - Just pushed a fix for this.