WPF Learning Path (eight) page

Source: Internet
Author: User

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

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.