开发者

What is the recommended WPF application project structure?

Hi I am quite new to WPF. I like the MVVM (Model-View-ViewModel) pattern. My current project has the following type of file/namespace structure:

  Clients
    Controls
      ClientNameControl.xaml
      ClientSurnameControl.xaml
    Views
      ClientCapture.xaml 
    Models
      Client.cs
    ViewModels
      ClientViewModel.cs

And so forth. With each domain object like clients, products etc. each having the structure above. Controls are used to compose views, very generic controls are split out into separate control projects and referenced in the project. My question is if this is a useful structure? All the examples of MVVM seem to take the following approach to file/namespace hierarchy:

  ViewModels
    Cl开发者_Python百科ientViewModel.cs
    ProductViewModel.cs
  Models
    Clients.cs
    Products.cs
  Views
    CliewntView
    ProductView

Any comments would be appreciated. Thanks in advance :)

UPDATE: I have been looking around and the below links provided useful information. I am going to structure my project the more traditional way.


We have 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

Also have a look at this SO question for some more info. related to WPF project structures - Recommended WPF Project Structure?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜