Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am building a touch-screen application, and I know I should avoid adding code to the code behind. Which leads to the question of how handle ManipulaitonDelta in the View Model. I have no idea how this can be done, and I am hoping someone can help me out.

Thanks!
Posted

1 solution

Avoiding code behind is not a universal truth that needs to always be applied regardless of context, does it apply in your case?

When people talk about avoiding code behind they usually refer to avoiding putting non UI specific logic into the code behind of a control as this couples the UI to tightly to the rest of the application logic. You don't want the code behind to be aware of and directly modify your business entities (such as a Customer or Order class), in such cases you'll want a view model de-coupling the UI by abstracting the view from the model.

But if you're building something that's a UI control (as I suspect from your question), then it is perfectly Ok in many cases to rely on code behind if the code is something that's tightly bound to the behaviour of the control rather than some application logic.

Consider WPF classes like Button or Grid, these classes aren't backed by view models but still have a lot of code behind because that code is control specific, not application logic specific.

Hope this helps,
Fredrik
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900