Click here to Skip to main content
11,574,494 members (70,105 online)

Design and Architecture

 
GeneralRe: Philosophical questions about updating a production CMS server Pin
KaЯl22-Aug-12 3:21
memberKaЯl22-Aug-12 3:21 
QuestionWebsite And Service Using Real Time Data Feed Pin
Member 8498734-Jul-12 5:34
memberMember 8498734-Jul-12 5:34 
AnswerRe: Website And Service Using Real Time Data Feed Pin
jschell5-Jul-12 6:15
memberjschell5-Jul-12 6:15 
GeneralRe: Website And Service Using Real Time Data Feed Pin
Albert Holguin17-Jul-12 10:18
memberAlbert Holguin17-Jul-12 10:18 
AnswerRe: Website And Service Using Real Time Data Feed Pin
Eddy Vluggen2-Aug-12 23:50
memberEddy Vluggen2-Aug-12 23:50 
AnswerRe: Website And Service Using Real Time Data Feed Pin
wizardzz9-Aug-12 8:15
memberwizardzz9-Aug-12 8:15 
QuestionCommonApplicationData Pin
mmujahid29-Jun-12 11:38
membermmujahid29-Jun-12 11:38 
AnswerRe: CommonApplicationData Pin
Richard Andrew x6429-Jun-12 11:51
memberRichard Andrew x6429-Jun-12 11:51 
QuestionBest Pattern for a New Service Pin
Brian C Hart26-Jun-12 9:12
memberBrian C Hart26-Jun-12 9:12 
SuggestionRe: Best Pattern for a New Service Pin
kisMicrosoftDev27-Jun-12 6:23
memberkisMicrosoftDev27-Jun-12 6:23 
AnswerRe: Best Pattern for a New Service Pin
jschell27-Jun-12 10:14
memberjschell27-Jun-12 10:14 
GeneralRe: Best Pattern for a New Service Pin
Brian C Hart27-Jun-12 11:00
memberBrian C Hart27-Jun-12 11:00 
AnswerRe: Best Pattern for a New Service Pin
jschell28-Jun-12 8:41
memberjschell28-Jun-12 8:41 
QuestionWPF App Design Thoughts Pin
Kevin Marois20-Jun-12 7:58
memberKevin 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
memberIan Shlasko20-Jun-12 8:06 
GeneralRe: WPF App Design Thoughts Pin
Kevin Marois20-Jun-12 8:29
memberKevin Marois20-Jun-12 8:29 
GeneralRe: WPF App Design Thoughts Pin
Pete O'Hanlon20-Jun-12 8:40
protectorPete O'Hanlon20-Jun-12 8:40 
GeneralRe: WPF App Design Thoughts Pin
Kevin Marois20-Jun-12 8:45
memberKevin Marois20-Jun-12 8:45 
GeneralRe: WPF App Design Thoughts Pin
Pete O'Hanlon20-Jun-12 8:56
protectorPete O'Hanlon20-Jun-12 8:56 
GeneralRe: WPF App Design Thoughts Pin
Kevin Marois20-Jun-12 8:59
memberKevin Marois20-Jun-12 8:59 
GeneralRe: WPF App Design Thoughts Pin
Kevin Marois20-Jun-12 9:01
memberKevin Marois20-Jun-12 9:01 
GeneralRe: WPF App Design Thoughts Pin
Pete O'Hanlon20-Jun-12 9:18
protectorPete O'Hanlon20-Jun-12 9:18 
GeneralRe: WPF App Design Thoughts Pin
Ian Shlasko20-Jun-12 9:43
memberIan Shlasko20-Jun-12 9:43 
GeneralRe: WPF App Design Thoughts Pin
Pete O'Hanlon20-Jun-12 9:49
protectorPete O'Hanlon20-Jun-12 9:49 
GeneralRe: WPF App Design Thoughts Pin
Ian Shlasko20-Jun-12 10:17
memberIan Shlasko20-Jun-12 10:17 
GeneralRe: WPF App Design Thoughts Pin
Kevin Marois20-Jun-12 10:29
memberKevin Marois20-Jun-12 10:29 
GeneralRe: WPF App Design Thoughts Pin
Ian Shlasko20-Jun-12 11:13
memberIan Shlasko20-Jun-12 11:13 
GeneralRe: WPF App Design Thoughts Pin
Kevin Marois20-Jun-12 11:20
memberKevin Marois20-Jun-12 11:20 
GeneralRe: WPF App Design Thoughts Pin
Ian Shlasko20-Jun-12 11:46
memberIan Shlasko20-Jun-12 11:46 
GeneralRe: WPF App Design Thoughts Pin
Kevin Marois20-Jun-12 11:47
memberKevin Marois20-Jun-12 11:47 
GeneralRe: WPF App Design Thoughts Pin
Ian Shlasko20-Jun-12 11:55
memberIan Shlasko20-Jun-12 11:55 
GeneralRe: WPF App Design Thoughts Pin
kishhr22-Jun-12 8:59
memberkishhr22-Jun-12 8:59 
QuestionThin Client Compiler ? Pin
W∴ Balboos19-Jun-12 6:28
memberW∴ Balboos19-Jun-12 6:28 
AnswerRe: Thin Client Compiler ? Pin
Eddy Vluggen19-Jun-12 8:55
memberEddy Vluggen19-Jun-12 8:55 
GeneralRe: Thin Client Compiler ? Pin
W∴ Balboos19-Jun-12 9:21
memberW∴ Balboos19-Jun-12 9:21 
GeneralRe: Thin Client Compiler ? Pin
Eddy Vluggen19-Jun-12 10:24
memberEddy Vluggen19-Jun-12 10:24 
GeneralRe: Thin Client Compiler ? Pin
W∴ Balboos20-Jun-12 1:41
memberW∴ Balboos20-Jun-12 1:41 
GeneralRe: Thin Client Compiler ? Pin
Eddy Vluggen20-Jun-12 1:54
memberEddy Vluggen20-Jun-12 1:54 
GeneralRe: Thin Client Compiler ? Pin
W∴ Balboos20-Jun-12 2:11
memberW∴ Balboos20-Jun-12 2:11 
GeneralRe: Thin Client Compiler ? Pin
Eddy Vluggen20-Jun-12 2:30
memberEddy Vluggen20-Jun-12 2:30 
AnswerRe: Thin Client Compiler ? Pin
jschell19-Jun-12 13:21
memberjschell19-Jun-12 13:21 
GeneralRe: Thin Client Compiler ? Pin
W∴ Balboos20-Jun-12 1:46
memberW∴ Balboos20-Jun-12 1:46 
AnswerRe: Thin Client Compiler ? Pin
Bernhard Hiller19-Jun-12 20:41
memberBernhard Hiller19-Jun-12 20:41 
GeneralRe: Thin Client Compiler ? Pin
W∴ Balboos20-Jun-12 1:58
memberW∴ Balboos20-Jun-12 1:58 
Questionprobleme schema object rational rose Pin
ahmadiss16-Jun-12 5:53
memberahmadiss16-Jun-12 5:53 
QuestionWhat's The Right Way To Do This? Pin
Kevin Marois15-Jun-12 7:26
memberKevin Marois15-Jun-12 7:26 
AnswerRe: What's The Right Way To Do This? Pin
Pete O'Hanlon15-Jun-12 7:58
protectorPete O'Hanlon15-Jun-12 7:58 
GeneralRe: What's The Right Way To Do This? Pin
Kevin Marois15-Jun-12 8:00
memberKevin Marois15-Jun-12 8:00 
GeneralRe: What's The Right Way To Do This? Pin
Eddy Vluggen17-Jun-12 8:36
memberEddy Vluggen17-Jun-12 8:36 
GeneralRe: What's The Right Way To Do This? Pin
jschell17-Jun-12 13:08
memberjschell17-Jun-12 13:08 

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

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


Advertise | Privacy | Mobile
Web03 | 2.8.150624.2 | Last Updated 30 Jun 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid