Reputation: 7253
I've a form with an image component : Image
I would like to get real mouse position in this image.
For that I use the formule below which is located in a function
mouseXInImage = MouseXInComponent / ComponentWidth * ImageSourceWidth
mouseYInImage = MouseYInComponent / ComponentHeight * ImageSourceHeight
ComponentWidth
and ComponentHeight
are part of the view.
So my question is about MVVM pattern : Where should be this function ?
In the code behind ? (because of the view, but there are logic too)
In the view model ? (because of the logic, but there are view)
Thanks
Upvotes: 2
Views: 85
Reputation: 6175
It's probably a question open for debate, but to me it looks like a very UI-related problem. The logic is linked to your UI. So it might make more sense in the view's codebehind.
One thing you can ask yourself is "If I was reusing this code for an other type of app (desktop, mobile, silverlight, etc.) would the code still be valid? If you answer yes, then it might be interesting to put in the VM, otherwise in the view (codebehind) is better.
Upvotes: 5