XAML简介
XAML是一种声明性标记语言,是eXtensible Application Markup Language的缩写。
一.XAML为元素设置属性,有以下几种方式:
1.XML特性语法:
<Button Background="Blue" Foreground="Red" Content="This is a button"/>
2.属性元素法:
<Button>
<Button.Background>
<SolidColorBrush Color="Blue"/>
</Button.Background>
<Button.Foreground>
<SolidColorBrush Color="Red"/>
</Button.Foreground>
<Button.Content>
This is a button
</Button.Content>
</Button>
3.内容元素法:
<TextBlock>Hello Silverlight</TextBlock>
二.XAML的一些重要特性:
1.以XML为基础的语言扩展。
2.必须是格式良好的XML。
3.XAML中的标记对应.NET Framework中的类型。
4.具备面向对象及继承的特性。
5.区分大小写。
6.XAML中能实现的,隐藏代码同样能够实现。
7.XAML也会创建元素树。