tags:

views:

67

answers:

1

Hi all What is the best practice for connecting a single data class which houses all information and communication to a UI coded in XAML? I am of course talking about the controller in MVC.

This one class, call it Manager, exposes certain functionality such as Login() and GetNetData() etc. The UI is entirely in XAML, so it seems easy to simply code in handlers directly for the components. For example a button saying "Login" will have its Click() executed and will then call Manager.Login() directly in the xaml.cs code.

Is there a better way of doing this for larger apps? The controller here seems to simply be the actual event handlers of the UI. What is best practice for this?

A: 

You might want to have a look at the MVVM pattern for this. It just works perfectly with WPF and its databinding infrastructure and almost completely eliminates the need for those one-liner events in the code behind just for calling a method on the controller. Look at this article for an introduction:

http://msdn.microsoft.com/en-us/magazine/dd419663.aspx

Botz3000