A Look on Window
While building your application, the first thing you notice is a Window. Window is the main class that interact with the user and produces the lifetime of windows and dialog boxes. Like in normal windows application, it produces the object windows using the normal API. A window has two sections.
1. Non-Client Area : which displays the outer boundary of the window, that we normally see with any windows. The main parts of them are Icon, System Menu, a title Bar and Border.
2. Client part : This is the main part where the WPF controls will appear. You can customize this area using WPF.
Types of Window:
WPF window is of 3 types.
1. Window : This is basically a normal windowed application, where every controls are placed within the same window. The window appears normally as I told you earlier. The Client area are fully customizable using XAML.
2. NavigationWindow : This is a special type of window which is inherited from Windows but with a Navigation panel top of it. So if you want to create an application that makes sense when used as Wizards, you might better go with Navigation Window. You can also customize the navigation panel yourself so that it goes with your own look and feel.
3. Page : Almost similar to NavigationWindow, the main difference is that, Page can be opened in Web Browser as XBAP applications.
In the above image you can see how Normal Window differs from NavigationWindow.
NavigationWindow is very uncommon in general case, but might come handy when you need special treatment for your application.
Let me discuss a bit on how you can use Pages in your application.
Pages are created to be used as a Page for the Same Window. Navigating from one page to another is very simple. Page Class exposes an object of NavigationService
which you can use to navigate between pages. NavigationService has few events like Navigating, NavigationFailed, NavigationProgress, NavigationStopped etc which you
can use to show progressbar while the page is navigating. Methods like GoBack, GoForward and Navigate are the best way to navigate from one page to another.
private void Button_Click(object sender, RoutedEventArgs e)
{
this.NavigationService.Navigate(new Uri("Page2.xaml", UriKind.Relative));
}Thus you can see, rather than calling a new window for Page2.xaml, I just used NavigationService to navigate from one page to another.
Types of Containers:
WPF Window is derived from ContentControl. Basically while working with Controls, you might come across a few types of controls which forms the basis for any WPF control. A ContentControl holds any arbitrary content. It may be a string, an object of any type or even an UIElement like Button, TextBox etc. In other words, A Content is an arbitrary element that might be placed inside a container.
Lets take a look at them one by one :
1. ContentControl : A ContentControl holds a single child Content. As Window is derived from ContentControl, every window can have only a single Child. For
Example : Window, Button etc.
2. HeaderedContentControl : It is basically the same as ContentControl, but additionally there is a header part which shows the Header for the Content. For instance, A GroupBox, Expander are HeaderedContentControl.
3. ItemsControl : The content of ItemsControl is multiple. Therefore you can place many arbitrary elements inside an ItemsControl. For Instance : ListBox, ListView are examples of ItemsControl.
4. HeaderedItemsControl : Here each Collection has a specific header content of it. A HeaderedItemsControl is a complex element which holds each content with a specific header. TreeView is an example of HeaderedItemsControl.
The above picture shows the distinction between different ContentControls. Each contentControl contains a Content property which stores the inner content. in your XAML you can specify using Content attribute, or you can directly write the Content inside the Tag. Thus,
<Button Content="This is a Button" />
is same as
<Button>This is a Button</Button>
XAML parser parses the element written inside the XAML ContentControl Tag as Content.
While building your application, the first thing you notice is a Window. Window is the main class that interact with the user and produces the lifetime of windows and dialog boxes. Like in normal windows application, it produces the object windows using the normal API. A window has two sections.
1. Non-Client Area : which displays the outer boundary of the window, that we normally see with any windows. The main parts of them are Icon, System Menu, a title Bar and Border.
2. Client part : This is the main part where the WPF controls will appear. You can customize this area using WPF.
Types of Window:
WPF window is of 3 types.
1. Window : This is basically a normal windowed application, where every controls are placed within the same window. The window appears normally as I told you earlier. The Client area are fully customizable using XAML.
2. NavigationWindow : This is a special type of window which is inherited from Windows but with a Navigation panel top of it. So if you want to create an application that makes sense when used as Wizards, you might better go with Navigation Window. You can also customize the navigation panel yourself so that it goes with your own look and feel.
3. Page : Almost similar to NavigationWindow, the main difference is that, Page can be opened in Web Browser as XBAP applications.
In the above image you can see how Normal Window differs from NavigationWindow.
NavigationWindow is very uncommon in general case, but might come handy when you need special treatment for your application.
Let me discuss a bit on how you can use Pages in your application.
Pages are created to be used as a Page for the Same Window. Navigating from one page to another is very simple. Page Class exposes an object of NavigationService
which you can use to navigate between pages. NavigationService has few events like Navigating, NavigationFailed, NavigationProgress, NavigationStopped etc which you
can use to show progressbar while the page is navigating. Methods like GoBack, GoForward and Navigate are the best way to navigate from one page to another.
private void Button_Click(object sender, RoutedEventArgs e)
{
this.NavigationService.Navigate(new Uri("Page2.xaml", UriKind.Relative));
}Thus you can see, rather than calling a new window for Page2.xaml, I just used NavigationService to navigate from one page to another.
Types of Containers:
WPF Window is derived from ContentControl. Basically while working with Controls, you might come across a few types of controls which forms the basis for any WPF control. A ContentControl holds any arbitrary content. It may be a string, an object of any type or even an UIElement like Button, TextBox etc. In other words, A Content is an arbitrary element that might be placed inside a container.
Lets take a look at them one by one :
1. ContentControl : A ContentControl holds a single child Content. As Window is derived from ContentControl, every window can have only a single Child. For
Example : Window, Button etc.
2. HeaderedContentControl : It is basically the same as ContentControl, but additionally there is a header part which shows the Header for the Content. For instance, A GroupBox, Expander are HeaderedContentControl.
3. ItemsControl : The content of ItemsControl is multiple. Therefore you can place many arbitrary elements inside an ItemsControl. For Instance : ListBox, ListView are examples of ItemsControl.
4. HeaderedItemsControl : Here each Collection has a specific header content of it. A HeaderedItemsControl is a complex element which holds each content with a specific header. TreeView is an example of HeaderedItemsControl.
The above picture shows the distinction between different ContentControls. Each contentControl contains a Content property which stores the inner content. in your XAML you can specify using Content attribute, or you can directly write the Content inside the Tag. Thus,
<Button Content="This is a Button" />
is same as
<Button>This is a Button</Button>
XAML parser parses the element written inside the XAML ContentControl Tag as Content.



No comments:
Post a Comment