Click here to Skip to main content
15,891,136 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
QuestionCommonApplicationData Pin
mmujahid29-Jun-12 11:38
mmujahid29-Jun-12 11:38 
AnswerRe: CommonApplicationData Pin
Richard Andrew x6429-Jun-12 11:51
professionalRichard Andrew x6429-Jun-12 11:51 
QuestionBest Pattern for a New Service Pin
Brian C Hart26-Jun-12 9:12
professionalBrian C Hart26-Jun-12 9:12 
SuggestionRe: Best Pattern for a New Service Pin
kisMicrosoftDev27-Jun-12 6:23
kisMicrosoftDev27-Jun-12 6:23 
AnswerRe: Best Pattern for a New Service Pin
jschell27-Jun-12 10:14
jschell27-Jun-12 10:14 
GeneralRe: Best Pattern for a New Service Pin
Brian C Hart27-Jun-12 11:00
professionalBrian C Hart27-Jun-12 11:00 
AnswerRe: Best Pattern for a New Service Pin
jschell28-Jun-12 8:41
jschell28-Jun-12 8:41 
QuestionWPF App Design Thoughts Pin
Kevin Marois20-Jun-12 7:58
professionalKevin Marois20-Jun-12 7:58 
I'm starting a new WPF app. The app's visual layout is pretty simple[^].

I have done apps like this before, but I'd like to revisit the way I do this.

Basically, the main content area contains a Content Presenter that is bound to a property called MainContent in the MainWindowViewModel. Then logic in the MainWindowViewModel determines which view to bind. The main content is then dynamic based of business logic.

For example, after installation there will be a series of views, like a wizard, that walks the user through the intial setup. Then, once up & running, what is displayed there is based off what action the user choise.

I had a conversion with a co-worker who was totally against this design because he thought that the VM's should not know about any views. He is right in that the MainWindowViewModel has a method called LoadView that accepts an enum containing the names of the content items to show.

So, if the user clicks a customer account, the click handler would pass AppViews.CustomerAccount to LoadView, and the LoadView method looks like this:

private UserControl _MainContent;
public UserControl MainContent
{
    get { return _MainContent; }
    set
    {
        if (_MainContent == value)
            return;
        _MainContent = value;
        RaisePropertyChanged("MainContent");
    }
}
        
public void LoadView(AppViews ViewToLoad)
{
    _ViewModeBase vm = null;
    UserControl view = null;

    switch (ViewToLoad)
    {
        case AppViews.CustomerAccount:
            vm = new CustomerAccountViewModel();
            view = new CustomerAccountView();
            break;

        // Once CASE for each view
    }

    view.DataContext = vm;
    MainContent = view;
}


Again, I have done this with success a few times, but I want to make sure it's a solid design.

Anyone have a better way?

Thanks
If it's not broken, fix it until it is

AnswerRe: WPF App Design Thoughts Pin
Ian Shlasko20-Jun-12 8:06
Ian Shlasko20-Jun-12 8:06 
GeneralRe: WPF App Design Thoughts Pin
Kevin Marois20-Jun-12 8:29
professionalKevin Marois20-Jun-12 8:29 
GeneralRe: WPF App Design Thoughts Pin
Pete O'Hanlon20-Jun-12 8:40
mvePete O'Hanlon20-Jun-12 8:40 
GeneralRe: WPF App Design Thoughts Pin
Kevin Marois20-Jun-12 8:45
professionalKevin Marois20-Jun-12 8:45 
GeneralRe: WPF App Design Thoughts Pin
Pete O'Hanlon20-Jun-12 8:56
mvePete O'Hanlon20-Jun-12 8:56 
GeneralRe: WPF App Design Thoughts Pin
Kevin Marois20-Jun-12 8:59
professionalKevin Marois20-Jun-12 8:59 
GeneralRe: WPF App Design Thoughts Pin
Kevin Marois20-Jun-12 9:01
professionalKevin Marois20-Jun-12 9:01 
GeneralRe: WPF App Design Thoughts Pin
Pete O'Hanlon20-Jun-12 9:18
mvePete O'Hanlon20-Jun-12 9:18 
GeneralRe: WPF App Design Thoughts Pin
Ian Shlasko20-Jun-12 9:43
Ian Shlasko20-Jun-12 9:43 
GeneralRe: WPF App Design Thoughts Pin
Pete O'Hanlon20-Jun-12 9:49
mvePete O'Hanlon20-Jun-12 9:49 
GeneralRe: WPF App Design Thoughts Pin
Ian Shlasko20-Jun-12 10:17
Ian Shlasko20-Jun-12 10:17 
GeneralRe: WPF App Design Thoughts Pin
Kevin Marois20-Jun-12 10:29
professionalKevin Marois20-Jun-12 10:29 
GeneralRe: WPF App Design Thoughts Pin
Ian Shlasko20-Jun-12 11:13
Ian Shlasko20-Jun-12 11:13 
GeneralRe: WPF App Design Thoughts Pin
Kevin Marois20-Jun-12 11:20
professionalKevin Marois20-Jun-12 11:20 
GeneralRe: WPF App Design Thoughts Pin
Ian Shlasko20-Jun-12 11:46
Ian Shlasko20-Jun-12 11:46 
GeneralRe: WPF App Design Thoughts Pin
Kevin Marois20-Jun-12 11:47
professionalKevin Marois20-Jun-12 11:47 
GeneralRe: WPF App Design Thoughts Pin
Ian Shlasko20-Jun-12 11:55
Ian Shlasko20-Jun-12 11:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.