开发者

using usercontrols instead of windows

I'm not sure if this is a bad way of building an application but let's say I have 30 WPF Windows for different screens in my application. I want to build them into a DLL so I was wondering if it is bad design to instead of creating each window as a window, if i can have 1 window that hosts whichever screen is open. So the windows will actually be a usercontrol, or at least act like one. So when you want to go to a different screen, you would just change the content of the 1 window to the conten开发者_高级运维t of the "usercontrol" that you want displayed. Does this make sense, or can you see issues with possibly doing this? Thanks.


That may be a good approach but you need to think about whether every screen belongs in the same window. For example is every user control going to use all of the space in the window, or will you have some visual issues? The content of your windows, your data, and how the windows manipulate that data may also have an impact.

You may want to look into design patterns such as MVC and MVVM (more popular with WPF).


This sounds like a much nicer solution than 30 separate windows :) Nothing wrong with it.

You might want to do some reading about presentation patterns to get a good understanding of how to manage applications with multiple screens. Take a look at this excellent (but incomplete) wiki on Presentation Patterns, based on a book in the making by Jeremy Miller with contributions from the great Martin Fowler.

Read through a summary of each of the patterns to get an idea if it applies to your situation, and if it does try Googling around. Many of the patterns in that wiki have evolved fairly recently and the best resources for them so far are disparate blog entries and obscure mailing lists. But it's worth doing the digging because there are some truly inspired gems of information to be found in this arena. Presentation patterns are a very interesting thing!


From what you told I'm thinking that maybe Pages are better for your use than controls. In that case you can user Frame control in main window to support navigation between pages (or hide navigation buttons and navigate from code directly).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜