Silverlight中的XAML

提起Silverlight就不能不提XAML,XAML是一种可扩展的应用程序标记语言(读作“zammel”),是一种可以直观的显示在 Blend或者可视化XAML编辑器上的一种语言,就如同HTML语言显示在浏览器上一样。其优点就是可以让表现层和数据层完全分离。WPF也有相同的方 式

1
2
3
4
5
6
7
8
9
< UserControl x:Class = "SilverlightApplication1.MainPage"
  mc:Ignorable = "d" d:DesignWidth = "640" d:DesignHeight = "480" >
  < Grid x:Name = "LayoutRoot" >
 
  </ Grid >
</ UserControl >

这个是我们新建一个MainPage.xaml的页面,UserControl是他的根元素,说明了这个类继承自UserControl 类,x:Class=”SilverlightApplication1.MainPage”,说明了,这个类的命名空间是 SilverlightApplication1,类名是MainPage。

上面例子中,xmlns 属性专门指默认的 xmlns 命名空间。在默认的 xmlns 命名空间中,可以不使用前缀指定标记中的对象元素。

xmlns:x 属性指示另外一个 xmlns 命名空间,该命名空间映射 XAML 语言命名空间 http://schemas.microsoft.com/winfx/2006/xaml 。在具有此映射的文件的标记中引用时,XAML 规范定义的所需语言组件带有 x: 前缀。

<Page根元素的开始对象元素
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”默认 (WPF) 命名空间
就类似于如下的C#代码:
using System.Windows;
using System.Windows.Automation
using System.Windows.Controls;
using System.Windows.Controls.Primitives
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Forms.Integration
using System.Windows.Ink
using System.Windows.Media.Animation
using System.Windows.Media.Effects
using System.Windows.Media.Media3D
using System.Windows.Media.TextFormatting
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”这是XAML语言命名空间,用于映射System.Windows.Markup命名空间中的类型,而且它也定义了XAML编译器或解析器中的一些特殊的指令。这些指令通常是作为XML元素的特性出现的,因此它们看上去像宿主元素的属性,但实际上并不是如此。
x:Class=”MyNamespace.MyPageCode”分部类声明,它将标记连接到此分部类中定义的任何代码隐藏
>根的对象元素的末尾,但由于页面包含子元素,因此尚未结束

原创文章,转载请注明: 转载自.NET开发者

本文链接地址: Silverlight中的XAML

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值