XAML




XAML WPF应用程序






XAML(Extensible Application Markup Language 聆聽i/ˈzæməl/)是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#






 1 <Window x:Class="MainWindow"
2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6 xmlns:local="clr-namespace:WpfAppExample"
7 mc:Ignorable="d"
8 Title="MainWindow" Height="350" Width="525">
9 <Grid>
10 <Button Margin="10,0,10,0" Height="100" Click="Hello_Click" Content="Click Me!"/>
11 </Grid>
12 </Window>














 1 using System.Windows;
2
3 namespace WpfAppExample
4
5 public partial class MainWindow : System.Windows.Window
6
7 public MainWindow()
8
9 InitializeComponent();
10
11
12 private void Hello_Click(object sender, System.Window.RoutedEventArgs e)
13
14 System.Windows.Froms.MessageBox.Show("Hello World!")
15
16
17






  • Visual Basic dotNet






 1 <Window x:Class="MainWindow"
2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6 xmlns:local="clr-namespace:WpfAppExample"
7 mc:Ignorable="d"
8 Title="MainWindow" Height="350" Width="525">
9 <Grid>
10 <Button Margin="10,0,10,0" Height="100" Click="Hello_Click" Content="Click Me!"/>
11 </Grid>
12 </Window>














 1 Imports System.Windows
2
3 Sub New()
4 InitializeComponent()
5 End Sub
6
7 Class MainWindow
8 Private Sub Hello_Click(sender As Object, e As System.Window.RoutedEventArgs)
9 System.Windows.Froms.MessageBox.Show("Hello World!")
10 End Sub
11 End Class







参考资料





外部連結


  • 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



Popular posts from this blog

京昆高速公路

【情報】本週珍珠商品重點:煉金時裝 + 艾港勞工宿舍!!

【攻略】陳戈-謝勒汗智慧的古書 (完成)