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 betwee
A page is something you would use in a browser, not for a standalone application.
The Window class represents a top-level object, that is, it is not meant to be contained in another control. All the windows you see while using the Windows OS (if they were WPF application) would be created by deriving from the Window class, and you would use the Window class to create your own windows.
The UserControl class lets you create new custom controls, in case a standard control does not already exist for what you need. A UserControl can be contained inside of a window or another control, but a Window is not contained inside anything (this is the big difference!)
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:
<Application x:Class="WpfApplication1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
The StartupUri
property 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:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
Title="Window1" Height="300" Width="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition />
</Grid.RowDefinitions>
<local:HeaderUserControl Grid.Row="0" />
<local:MainSectionUserControl Grid.Row="1" />
</Grid>
</Window>
where HeaderUserControl
and MainSectionUserControl
are UserControls encapsulating the aspects of that Window, as needed.
If you want to show another Window, you can, in code, call Show
or ShowDialog
on 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.