I got an assignment to make a Desktop application using C#. It has to be done using MVC design pattern, but I can't find any tutorial which can show how to do it with Desktop based application. All the tutorials which I can find show how to do it for web (asp.net).
So I was wondering if someone can suggest me a book or online tutorial which is doing this?
I always learned by doing so here's a very basic example. Web or Windows, doesn't matter...
Model
// basic template for what your view will do
public interface IProgram
{
public string FirstName { get; set; }
}
View
public class Program : IProgram
{
ProgramController _controller;
public Program()
{
// pass itself to the controller
_controller = new ProgramController(this);
}
public string FirstName
{
get { return firstNameTextBox.Value; }
set { firstNameTextBox.Value = value; }
}
}
Controller
public class ProgramController
{
IProgramView _view;
public ProgramController(IProgramView view)
{
// now the controller has access to _view.FirstName
// to push data to and get data from
_view = view;
}
}
You can bind any members this way, such as events
Since this is homework, I believe that you teacher and, more importantly, yourself, desire to learn the tricks behind MVC. So, while checking MVC Frameworks might help, I recommend you implement basic functionality on your own.
That said, take a look at Wikipedia's article first (which, unfortunately isn't that good), then check Microsoft's take on it.
Once you grasp the concepts, try implement a basic triplet that does "something", nothing really fancy. If you have doubts, come back to SO so that we can solve then. And don't forget the new chat functionality of SO.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With