A damn at Han's Windows Phone Book notes (6: page navigation & Data Binding)

Source: Internet
Author: User

Navigationservice

Use navigate to open a page:

This. navigationservice. navigate (New uri ("/instructionspage. XAML", urikind. Relative ));

You can also use Goback and goforward to open a page.

Goback and goforward are used to open the instance on the previous page, but navigate is used to open a new instance.

 

Do not display the back and forward buttons. The back button has a physical button and the forward button is unnecessary. Goforward pushes the current page to the back stack and clears the forward stack.

If you want to cancel it, you can use the cancel button.

 

Transfer Data between pages

1. Static variables.

2. query string: The data is transmitted using the included parameters. Restrictions: data can only be passed forward, but not backward. parameters must be easily expressed using strings.

This. navigationservice. navigate (

New uri ("/detailspage. XAML? Categoryindex = "+ this. categoryindex +" & signindex = "+ this. ListBox. selectedindex, urikind. Relative ));

Assign Parameters

If (this. navigationcontext. querystring. containskey ("categoryindex") contains a parameter

Int. parse (this. navigationcontext. querystring ["categoryindex"]) parse the Parameter

 

Data Binding

You can set binding in XAML first, C #CodeTo complete the binding.

Example: This. datacontext = sign;

Datacontext is of the object type, so you can assign a value to any object. The child element on the page inherits the datacontext of its parent element.

In addition, the itemsource attribute is relatively simple to bind.

For example:

Foreach (sign in data. categories [This. categoryindex]. Signs)
{

This. ListBox. Items. Add (sign );

}

Because ListBox has the itemsource attribute, you can call it as follows:

This. ListBox. itemssource = data. categories;

 

Inotifypropertychanged Interface

To automatically update the UI of a property bound to an object, you must implement the object category.Inotifypropertychanged interface, the method is as follows:

 Public class  Userinfo : Inotifypropertychanged { Public String Username { Get ; Set ;} Private int Age; Public int Age { Get { Return this . Age ;}Set { If ( This . Age! = Value ){ This . Age = Value ; Onpropertychanged ( "Age" );}}} # Region Inotifypropertychanged members Public event  Propertychangedeventhandler Propertychanged; Private void Onpropertychanged (String Propertyname ){ Propertychangedeventhandler Handler = This . Propertychanged; If (Handler! = Null ) {Handler ( This , New  Propertychangedeventargs (Propertyname ));}} # Endregion }

For more information about data binding, see http://www.cnblogs.com/Jax/archive/2009/10/13/1582128.html

 

Strech attributes of images

 

When should URI start /?

Navigation URI must have

The URI of the resource file pointing to buitldaction = resource must not exist.

Indicates whether the URI of the resource file pointing to buitldaction = content can be used.

You can simply remember that there is a navigation Uri and no resource file.

 

Each App should have an about page.

Method for obtaining the version number:

  try  { string  S =  typeof  ( aboutpage  ). assembly. tostring (); /s form, for example, windowsphoneapp, version = 1.0.0.0, culture = neutral, publickeytoken = NULL   If  (s! =  null  & S. indexof ( "version =" )> = 0) {S = S. substring (S. indexof ( "version =" ) + " version = ". length); s = S. substring (0, S. indexof ( "," );  This . versiontextblock. TEXT = " version " + S ;}< span style =" color: Blue "> catch {< span style =" color: green ">/* Never mind! */}

in this way, you only need to change the version number of the Program set. The version number displayed by the user is automatically updated.

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.