XAML(Extensible Application Markup Language )是Windows Presentation Foundation(WPF)和Universal Windows Platform(UWP)的一部分,是微软开发的一種基于XML、基于声明,用于初始化结构化值和对象的使用者介面宣告式程式設計,它有著HTML的外觀,又揉合了XML語法的本質,例如:可以使用****標籤設定按鈕(Button)。它類似Linux平台下的glade。至於WinFX XAML Browser Application(XBAP)是用XAML作界面描述,在瀏覽器中執行的程式,可取代過去的ActiveX、Java Applet、Flash。
XAML本質上屬於一種.NET编程语言,屬於通用語言運行庫(Common Language Runtime),同C#、VB.NET等同。與HTML類似,特点是用來描述使用者介面。XAML的语法格式为:,Application是必備的基本元素。XAML可以定義2D和3D物件、旋轉(rotations)、動畫(animations),以及各式各樣的效果。
Hello world
- C# UWP
using System;
using Windows.UI.Xaml.Controls;
namespace UwpAppExample
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
private async void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
await new Windows.UI.Popups.MessageDialog("Hello World!").ShowAsync();
}
}
}
- C# WPF
using System.Windows;
namespace WpfAppExample
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Hello_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("Hello World!");
}
}
}
- Visual Basic dotNet
Imports System.Windows
Class MainWindow
Sub New()
InitializeComponent()
End Sub
Private Sub Hello_Click(sender As Object, e As RoutedEventArgs)
MessageBox.Show("Hello World!")
End Sub
End Class
参考资料
外部連結
- [https://web.archive.org/web/20060717193028/http://windowssdk.msdn.microsoft.com/en-us/library/ms752059.aspx Microsoft XAML overview]
- [http://www.XAMLdev.com/ XAMLdev.com] A selection of categorized resources on XAML
- [http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnintlong/html/longhornch03.asp?frame=true XAML Controls from Microsoft Longhorn Developer Introduction]
- [http://www.Xaml.Net/ XAML used in Microsoft .NET platform]
- [http://html.xamjwg.org/ XAMJ, open source Java based project]
- [http://xaml.sourceforge.net United XAML Initiative] - Open Source XAML Alternatives
- [https://web.archive.org/web/20061029033418/http://www.shaxam.com/ Shaxam] - LightWave to XAML converter
- [http://techwritetips.wordpress.com/2006/10/06/what-is-xaml-authorings-best-kept-secret/ XAML and Technical Authors] A discussion of the affect of the open nature of XAML.
- [https://web.archive.org/web/20061126063128/http://www.netfxguide.com/guide/xaml.aspx XAML page on NetFXGuide.com] A selection of categorized resources on XAML.
- [http://www.learnwpf.com/ LearnWPF Website to learn WPX.]
- [https://web.archive.org/web/20061126164132/http://www.community-credit.com/cs/forums/49/ShowForum.aspx XAML Discussion Board] - A great discussion board for questions on XAML and the WPF
评论 (0)