I’m developing a new desktop application that will have several views such as a dashboard, event viewer, chart viewer to name a few. Essentially the user will switch between one of these view which will cover the whole screen and not just a part of it.
I’m currently stuck on whether I should be creating a new Window, Page or UserControl for each dashboard, event viewer, chart viewer etc.
I have done some reading and understand that Pages were built for navigation which in turn lets me keep a history of the navigation so I can go back/forward. However I don’t think I need that functionality for my desktop application.
So can I use either a UserControl or a Window? Or should there only be one Window per application?
Thanks
A Window has things like Title bar (including min/max/close buttons, etc) and can be used to host XAML elements, such as User Controls.
You are certainly not restricted to using one Window per Application, but some applications would choose that pattern (one window, hosting a variety of UserControls).
When you create a new WPF Application, by default your app is configured (in App.xaml) like this:
The
StartupUriproperty tells the app which Window to open first (you can configure this if you wish)If you would like to logically separate your Window into pieces and do not want too much XAML in one file, you could do something like this:
where
HeaderUserControlandMainSectionUserControlare UserControls encapsulating the aspects of that Window, as needed.If you want to show another Window, you can, in code, call
ShoworShowDialogon an instance of the new Window you want to show…Also – yes, a Page is part of a WPF Browser application, designed to be viewed in Internet Explorer.