Recommended WPF Project Structure?

13.8k Views Asked by At

I'm a stickler for good Visual Studio Solution and Project structures.

I'm about to start a WPF proof of concept piece of work.

Can anyone recommend some WPF Project structures they have used and found worked well?

Here http://drwpf.com/blog/2007/10/01/58/

They have one recommendation which I like:

    Root
    - Pages
    - Controls
    - Resources
    App.xaml

Where Pages, Controls and Resources are folders.

Has anyone found certain structures work well / don't work well?

Also I'd rather not get into a 'Model View Presenter' discussion if that's ok with you guys.

3

There are 3 best solutions below

1
On

I fully support the concern expressed in this post. I just can´t work without a solid previously thought-out structure. I am even going a bit further and trying to establish something like a pseudocode workflow which, in theory, could be filled out task by task, hopefully with the help of the IDE. At the moment I can share with whoever is interested a preliminary workflow that I created with Bing: preliminary wfw for creating a TreeView+DataGrid From this (10 years old!?) post, I can see that there is a lot more to this than what I have come up with, but it is doable. Of course, the type of applications would first have to be identified. Mine would be of the type WPF-DBFirst-desktop, and the current window would be of the type TreeView-DataGrid, the code could be created from one or several patterns and in different languages. And, after 4 months of working alongside Bing, I can see that AI would be a very powerful help for this. When will Microsoft/Visual Source include the possibility for our code to be reviewed for errors by AI? Wouldn´t that make life easier? particularly when you are 80 and it is your first app?

1
On

I tend to have the following directories: Converters, Models, Resources, ViewModels and Views.

I've also seen a solution where the View and ViewModels have been split out into separate projects (see BubbleBurst on CodePlex)

5
On

I agree with alimbada. We have also created different projects for View and View models. It makes things easier to maintain in case of huge projects. Directories we had were -

 - ViewsRoot
    + Base
    + Controls 
    + Documentation 
    + Forms(Windows)
    + Reports
    + Resources 
    + Themes 
    + Utilities 
    App.xaml

 - ViewModelsRoot
    + Collection
    + Commands
    + Converters
    + Resources 
    + TemplateSelectors
    + ViewModels
    + Views (Interfaces for views) 
    Constants.cs 
    Utility.cs

I also believe in planning the structure in advance, this makes easy for all developers to get used to it and follow the same. Doing this later adds confusion and is painful in case you have to create seprate projects. Thats my view and am open to know of other better approches for this.