WPF learning path (8) page, wpf learning path page
Traditional applications have two application modes: desktop applications and Web applications. WPF navigation applications blur the boundaries between these two types of applications.
WPF navigation is represented in two forms: one is to host the navigation content in the window, the other is the XAML Browser Application
Four core elements: Page \ HyperLink \ NavigationServices \ Journal
Page
The Page in WPF is more streamlined than the Window. Instead of providing a Show or Hide method, It switches pages through links. Generally, the Page size is not set because the size of the Page is determined by the host form containing it.
Create a Page
Public partial class MyCustomPage: Page {public MyCustomPage () {InitializeComponent (); this. title = "window size not configured";} public MyCustomPage (double width, double height, double hostWinWidth, double hostWinHeigth): this () {this. width = width; this. height = height; this. required wwidth = hostWinWidth; this. required wheight = hostWinHeigth; this. title = "configure the window size"; this. text. text = "Width =" + width + "\ n" + "Height =" + height + "\ n" + "fill wwidth =" + hostWinWidth + "\ n "\ n "+" Running wheight = "+ 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){ NavigationWindow win = new NavigationWindow(); win.Content = new MyCustomPage(); //win.Content = new MyCustomPage(300, 300, 500, 500); //win.Content = new MyCustomPage(500, 500, 300, 300); win.Show();}
In three cases
The Page host window includes the browser, NavigationWindow, and Frame
The last two types 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 into other controls.
Create a Page and observe the differences between the two controls.
<Border BorderBrush = "Blue" BorderThickness = "2" Margin = "2"> <TextBlock x: name = "text" Text = "the host window of this page is a Frame" HorizontalAlignment = "Center" verticalignment = "Center"/> </Border>
CustomPage
<Border BorderBrush = "Red" BorderThickness = "2" Margin = "2"> <Grid. rowDefinitions> <RowDefinition/> </Grid. rowDefinitions> <TextBlock Grid. row = "0" x: name = "text" Text = "the host window of this page is a NavigationWindow" HorizontalAlignment = "Center" verticalignment = "Center"> </TextBlock> <Frame Grid. row = "1" Source = "SimplePage. xaml "NavigationUIVisibility =" Visible "> </Frame> </Grid> </Border>
To be continue...