WPF learning path (8) page, wpf learning path page

Source: Internet
Author: User

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...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.