XAML


XAML (正體)

XAML WPF Application

Extensible Application Markup Language,XAML,是WPF(Windows Presentation Foundation)的一部分,是一种XML的用户界面描述语言,有着HTML的外观,又揉合了XML语法的本质,例如:可以使用<Button>标签设置按钮(Button)。类似Linux平台下的glade。至于WinFX XAML Browser Application(XBAP)是用XAML作界面描述,在浏览器中运行的程序,可取代过去的ActiveXJava Applet、Flash。

XAML本质上属于一种.NET Programming Language,属于共同语言运行时期(Common Language Runtime),同C#VB.NET等同。与HTML类似,特点是用来描述用户界面。XAML的语法格式为:<Application... />,Application是必备的基本元素。XAML可以定义2D 和 3D 对象、旋转(rotations)、动画(animations),以及各式各样的效果。

Hello world

Page1.xaml
<Page
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
   <Button>Hello, world!</Button>
</Page>

Page1.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;

namespace WpfSample
{
 public partial class Page1 : Page
 {
   void HelloWorld(object sender, RoutedEventArgs e)
   {
     MessageBox.Show("Hello, world!");
   }
 }
}
 <Canvas>
   <Button Name="button1" Click="Clicked">Click Me!</Button>
   <x:Code><![CDATA[
     void Clicked(object sender, RoutedEventArgs e)
     {
         button1.Content = "Hello World";
     }
   ]]></x:Code>
 </Canvas>

外部链接







stock | retire | vm
Why are we here?
All text is available under the terms of the GNU Free Documentation License
This page is cache of Wikipedia. History