WPF Calling a custom command on a custom control (from a viewmodel?)
Posted
by user190615
on Stack Overflow
See other posts from Stack Overflow
or by user190615
Published on 2010-06-04T21:50:18Z
Indexed on
2010/06/05
10:22 UTC
Read the original article
Hit count: 149
I want to take a snap of the visual tree of a custom wpf control when the user clicks a button in a toolbar. The control is bound to a viewmodel.
I have a BitmapSource dp in the custom control holding the snapped image which is bound to a property on my VM. The BitmapSource dp on the control is updated via a custom command on the control. I've tied the toolbar button's command to call the controls command which updates the BitmapSource.
Now the problem is the end result I want is when the user clicks the button, the control updates its image and then the vm offers to save this image. I cant wrap my mind around an mvvm way of doing this.
One inelegant solution is that control fires an event after the image is updated which is routed to the viewmodel as a command(command behavior) but then if i want to do something else with the image on some other button click, all the commands bound to the events will fire.
All thoughts appreciated.
EDIT The command on the control is a RoutedCommand and the commands in my vm are Prism delegate commands.
© Stack Overflow or respective owner