Skip to content

Instantly share code, notes, and snippets.

@jen20
Created February 11, 2014 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jen20/8930380 to your computer and use it in GitHub Desktop.
Save jen20/8930380 to your computer and use it in GitHub Desktop.
Binding double clicking a data grid to a ReactiveCommand
Observable.FromEventPattern<MouseButtonEventHandler, MouseButtonEventArgs>
(h => JobsGrid.MouseDoubleClick += h, h => JobsGrid.MouseDoubleClick -= h)
.InvokeCommand(this, v => v.ViewModel.GoToJob);
@anaisbetts
Copy link

I bet you can do even better if you use ReactiveUI.Events:

JobsGrid.Events().MouseDoubleClick
    .InvokeCommand(this, v => v.ViewModel.GoToJob);

@jen20
Copy link
Author

jen20 commented Feb 11, 2014

I could, except it doesn't appear to expose MouseDoubleClick - that was the first thing I tried :-)

JobsGrid is a System.Windows.Controls.DataGrid by the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment