C
C#7mo ago
Denis

✅ Execute ICommand while button is pressed

In my WPF view I have a 9x9 grid of buttons representing movement controls: up, down, left, right, home. I wish to press and hold such a button to execute a Viewmodel command until the button is released. These buttons would serve to move the viewport of a canvas. Afaik, this isn't possible directly, as a button command is invoked on click. So this will probably require some markup extension to attach to the button events directly; however, my attempts were not fruitful. How would you implement such a feature?
3 Replies
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Mayor McCheese
Mayor McCheese7mo ago
The functionality as you describe doesn't seem like it would belong to a viewmodel tbh, so I agree with @Duke here, this is just going to be window events. why would your viewmodel care about the viewport?
Denis
Denis7mo ago
Hmm ok, I'll think about it a bit harder. Thanks!