计算机科学

首页 > 计算机科学

XAML

2018-09-06 14:14:43     所属分类:置标语言
XAML WPF应用程序

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

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

Hello world(C#)

 '''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>

参考资料

外部链接

  • Microsoft XAML overview
  • XAMLdev.com A selection of categorized resources on XAML
  • XAML Controls from Microsoft Longhorn Developer Introduction
  • XAML used in Microsoft .NET platform
  • XAMJ, open source Java based project
  • United XAML Initiative - Open Source XAML Alternatives
  • Shaxam - LightWave to XAML converter
  • XAML and Technical Authors A discussion of the affect of the open nature of XAML.
  • XAML page on NetFXGuide.com A selection of categorized resources on XAML.
  • LearnWPF Website to learn WPX.
  • XAML Discussion Board - A great discussion board for questions on XAML and the WPF


上一篇:VML语言
下一篇:XForms

猜你喜欢

相关推荐