WPF Study Notes 1 & mdash; XAML 1, wpf Study Notes xaml

Source: Internet
Author: User

WPF Study Notes 1--XAML 1, wpf Study Notes xaml

References:

Http://msdn.microsoft.com/zh-cn/library/ms752059 (v = vs.110). aspx

Pro WPF 4.5 in C #

I. XAML Overview

1. What is XAML?

Extensible Application Markup Language (read as zammel) is a declarative Markup Language used to instantiate. Net.

2. What is the purpose of XAML?

When you use Visual Studio to write a WPF program, the Window you designed is not converted into code, but into a series of XAML labels. When you run this WPF program, the tag code will generate objects on the user interface.

3. Why Learning XAML?

Although you can use Visual Studio to design windows, learning XAML helps you better learn the concept of WPF. More importantly, to better complete many WPF programs, we need to hand-Write the XAML file. Some developers like to design the UI Through Visual Studio, and then adjust the details by editing the XAML file. However, in some cases, writing a fully-handwritten XAML file may be a better choice.

Ii. XAML Basics

1. Basic Features

I. object element)

The object element syntax always starts with a left angle bracket (<. To complete the object element tag, end with a right angle bracket (>), or use a forward slash followed by a right angle bracket (/>) to complete the tag.

Each XAML object element matches the. NET class name. For example:

<StackPanel>  <Button Content="Click Me"/></StackPanel>

In this example, StackPanel and Button are two object elements.

Ii. Object Attributes)

You can use the value assignment operator (=) to set features in the object element label. The feature value is always specified as a string contained in quotation marks.

Iii. For some attributes of an object element, the feature syntax is impossible, because it is impossible to fully express the objects or information necessary to provide attribute values within the quotation marks and string restrictions of the feature syntax. In these cases, you can use another syntax, namely the property element syntax <type name. property Name>. Generally, the content of the tag is an object element of the type, and the attribute uses this element as its value. After the content is specified, an end tag must be used to end the attribute element. The end tag syntax is </type name. attribute name>. For example:

<Button Background="Blue" Foreground="Red" Content="This is a button"/>

In this example, three attributes are set for the Button object element: Background, Foreground, and Content.

2. root element, xmlns, xmlns: x

A simple XAML file:

<Window x:Class="WpfApplication1.Window1"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        Title="Window1" Height="300" Width="300">    <Grid>        <Button Content="Button" HorizontalAlignment="Left" Margin="112,79,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>    </Grid></Window>

I. a XAML file can only have one root element: Window, Page, Application, and so on. Window or Page is used for pages, ResourceDictionary is used for external dictionaries, or Application is defined for applications. For example, when a Window label ends, the XAML ends.

Ii. The root element also contains the feature xmlns and xmlns: x. Xmlns indicates the default XAML namespace. For most WPF application solutions, the default XAML namespace is mapped to the WPF namespace http://schemas.microsoft.com/winfx/2006/xaml/presentation.

Iii. xmlns: x indicates another XAML namespace, which maps to the XAML language namespace http://schemas.microsoft.com/winfx/2006/xaml. This namespace is a specialized XAML namespace that supports the construction of The XAML language.

For x: prefix programming constructs, see XAML namespaces (x :) language functions (http://msdn.microsoft.com/zh-cn/library/ms753327 (v = vs.110). aspx)


How does wpf display a xaml page on the tabContrl page?

<TabControl>
<TabItem>
<TabItem. Header>
Student Information
</TabItem. Header>
<ContentControl Margin = "10" Content = "{Binding Path = StudentInfo}"/>
</TabItem>
</TabControl>

Background: Public StudentInfoViewMode StudentInfo {get; private set ;}
You can't understand it. I have a lot of programs. I can only pull them out to show you a little bit. Hope to help you.

Beginner? How can I set the first window of VS2010 C # WPF project not MainWindowxaml? What is the difference between a page and a window?

No difference

By default, the first window is set to MainWindow. xaml.

You can modify the start page in the app.

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.