In WPF via XAML through to my viewModel, I want to detect mouse move on a Canvas, and react to it only when the left mouse button is pressed. Specifically I want to get the event from a method in my viewModel, including mouse position and mouse button states. Can someone help me with this?
I know I could use regular WPF events in code-behind, but doing that would be “surrendering” in my opinion, surrendering to the XAML learning curve, so that is last-resort.
I found this question, but I can’t afford Expression Blend, so it does not help me:
WPF Mouse Over
I looked in to
<EventTrigger RoutedEvent="Canvas.MouseMove"> . . .,
but that looks like it is only for animations.
It seems like this would be a common thing for people to want to do, but I can’t find anything on it.
You can create an attached behavior of canvas that accepts the command and raise it and your view model will subscribe to that command and perform the action.