Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing dot net desktop application with MVC design pattern

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?

like image 754
itsaboutcode Avatar asked Jan 05 '11 19:01

itsaboutcode


2 Answers

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

like image 110
hunter Avatar answered Sep 28 '22 20:09

hunter


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.

like image 24
Bruno Brant Avatar answered Sep 28 '22 18:09

Bruno Brant