There are two types of application patterns in traditional applications: desktop applications, Web applications. The third type of application where WPF's navigation application blurs the boundaries of these two types of applications
WPF navigation behaves in two forms, one is to host the navigation content in the window, and the other is the XAML browser application
Four core elements: Page\hyperlink\navigationservices\journal
Page
The page in WPF is more streamlined than window and does not provide a show or hide method, but rather a link to the page switch. In general, page does not set its own size, because the size of the page is determined by the host form that contains it.
Create a new page
Public Partial classmycustompage:page{ PublicMycustompage () {InitializeComponent (); This. Title ="no configuration for window size"; } PublicMycustompage (DoubleWidthDoubleHeightDoubleHostwinwidth,Doublehostwinheigth): This() { This. Width =width; This. Height =height; This. WindowWidth =Hostwinwidth; This. WindowHeight =hostwinheigth; This. Title ="Configuring the window size"; This. text. Text ="width="+ width +"\ n"+"height="+ Height +"\ n"+"windowwidth="+ Hostwinwidth +"\ n"+"windowheight="+hostwinheigth; }}
App.xaml
<application x:class="alex_wpfappdemo05.app" xmlns=" Http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x=" Http://schemas.microsoft.com/winfx/2006/xaml " Startup="application_startup">
App.xaml.cs
Private void Application_Startup (object sender, StartupEventArgs e) { new NavigationWindow (); New mycustompage (); // win. Content = new Mycustompage ( +, +); // win. Content = new Mycustompage (a); win. Show ();}
Three kinds of cases
Page's host window includes browser, NavigationWindow, Frame
The latter two are provided by WPF, which can record page navigation records and provide a series of navigation events. NavigationWindow is a top-level window that cannot be embedded into other controls, the frame is lightweight and can be embedded in other controls
Create a new page to observe the differences between the two controls
<border borderbrush="Blue"borderthickness="2"margin="2"> <textblock x:name="text"text="the host window of the page is a frame"Horizontalalignment="Center"Verticalalignment="Center"/> </Border>
Custompage
<border borderbrush="Red"borderthickness="2"margin="2"> <Grid> <Grid.RowDefinitions> <rowdefinition/> < RowDefinition/> </Grid.RowDefinitions> <textblock grid.row="0"X:name="text"text="the host window of the page is a NavigationWindow"HorizontalAlignment="Center"Verticalalignment="Center"></TextBlock> <frame grid.row="1"Source="Simplepage.xaml"navigationuivisibility="Visible"></Frame> </Grid> </Border>
To be continue ...
WPF Learning Path (eight) page