Windows Phone 8 Beginner's Tutorial (iv) Introduction to XAML

Source: Internet
Author: User
Tags constructor

Original address:

Http://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Beginners/Part-4-Introduction-to-XAML

Series Address: Http://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Beginners

Source code: HTTP://AKA.MS/ABSBEGINNERDEVWP8 PDF Version: http://aka.ms/absbeginnerdevwp8pdf

In this lesson, I'll discuss the XAML syntax for the Soudboard application written in the first lesson. I want you to notice how the XAML we write affects what we see in the Phone preview pane. It is relatively straightforward to see XAML as an absolute basic XAML, but I want to point out some features and features that are not seen at first glance.

The plan for this lesson is to outline:

We will discuss the purpose and nature of XAML by comparing it to C #

We will discuss the special features of XAML, some of the hidden features of the language, which are not obvious at first glance.

My goal: When this lesson is over, you will have enough knowledge of the XAML that we have written in the rest of this series, and I can basically guess what it will do before I try to explain it.

1. What is XAML?

In the last lesson I mentioned that XAML looks like HTML. This is no accident. XAML is actually XML (extensible Markup Language the extensible Markup Language). I'll explain their relationship later, but in summary, XML is very similar to HTML, and they have a common ancestor. HTML is used to build Web page documents, while XML is more generic. "GENERIC" here means that you can use it for any intended purpose, and you can define the names of elements and attributes (attributes) to suit your needs. In the past, developers used XML to store application settings, transferring data between two different systems. In order to use XML, you need to define a schema that declares the names of elements and element attributes. The architecture is similar to a contract (contract). Everyone, whether he is a producer of XML or a user of XML, complies with the terms of the contract to communicate with each other. So architecture is an important part of XML. Please remember the above analysis and we will discuss him later.

XAML is a special use of XML. Obviously, we've seen XAML related to the user interface that defines the phone. So at this point it feels very much like HTML. But there is a big difference between the fact that the XAML is actually used to create the instance of the class and the values of the Settings property (properties). For example, in the previous lesson we defined a button in XAML:

The above code is roughly equivalent to the following C # code:

I have added the above C # code to the constructor of the MainPage class. I'll talk about the relationship between MainPage.xaml and MainPage.xaml.cs later, but we've seen how to define behavior in MainPage.xaml.cs by writing program-style C # code. Here I've just written code that executes when a new instance of the MainPage class is created (by writing code in the class's constructor).

Now I have two buttons, one that is defined in XAML declaratively, contains "content Hello World" and rattles when the button is clicked, and the newly created button that contains the content "quack". When we run the application:

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/

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.