views:

140

answers:

2

Just starting out using model view controller design pattern in a mobile application and I have a quick query.

Basically if I have a listview control on my view and my controller needs to access properties on the listview when an action is performed, like the items checked and the listviewitem vales, do I just expose on my view interface a property of type Listview which returns the listview to my controller?

+2  A: 

No, because your view interface shouldn't really be technology specific. Ideally you should expose some kind of an abstraction of a listview. It's better to think about an abstract user interface when designing UI using MVC/MVP. Do not jump too early to designing controls.

BTW: I recommend using MVP instead of MVC. See an example code using MVP on Winforms: http://stackoverflow.com/questions/654722/implementing-mvc-with-windows-forms/685722#685722

Here are some links that can help you decide between MVC and MVP:

Igor Brejc
+1  A: 

You should define a interface that your form class implements. The interface will have properties and methods that will allow the underlying UI classes to query or control the form. If you decide to change the form (like use a treeview instead of a listview) all you have to focus on is changing the code implementing the interface.

RS Conley