1

I am working on a WPF application and following MVVM. I have 5 user controls. In one of my user control I need to handle a window message WMCOPY. How should I do that.

Can WPF User control handle windows messages events in its view model? If yes then how? And if no then how to do this?

And what is the proper way of doing this through MainWindow. How to propagate message to appropriate view model.

fhnaseer
  • 7,159
  • 16
  • 60
  • 112
  • WPF controls are not "windows" in OS sense, so you won't be able to handle window messages (only top-level windows are actually windows). What are you trying to achive? – Athari Jun 10 '13 at 09:37
  • I am getting some points information through a window message, and I need to update my view textboxes with these values. – fhnaseer Jun 10 '13 at 09:39
  • How should I do this through MainWindow. How to propagate this message to appropriate view model. – fhnaseer Jun 10 '13 at 09:39
  • You can start here: http://stackoverflow.com/q/624367/293099 As to MVVM implementation, you can try using attached properties to connect WndProc hook to your model. – Athari Jun 10 '13 at 09:46

1 Answers1

0

You could listen for the WMCOPY message and Execute a (matching) Command on the DataContext.

That way the response to the WMCOPY message is handled by the ViewModel.

Emond
  • 50,210
  • 11
  • 84
  • 115