WPF专业编程指南 - 那些根元素<>的解释

1 <Window x:Class="Chapter1_WpfApplication1.MainWindow"
2         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4         Title="MainWindow" Height="350" Width="525">
5 </Window>

1. <Window>代表了一个 XAML 文档的根元素,一个 XAML 文档只能有一个根元素

2. x:Class 只能有一个,是 Code Behind 的概念代码分离技术的体现,它表示一个“类”,类名是“MainWindow”,在命名空间“Chapter1_WpfApplication1”中

3. 该 XAML 的默认命名空间是“http://schemas.microsoft.com/winfx/2006/xaml/presentation”,另一个常用命名空间是“http://schemas.microsoft.com/winfx/2006/xaml”,这两个NameSpace合起来就能包含 WPF 所有可使用的对象了

4. 还可以将两个命名空间合并为一个 XAML 命名空间,方法是在项目中的AssemblyInfo.cs中使用XmlnsDefinition属性:

1 [assembly:XmlnsDefinition("自定义命名空间","已存在的命名空间1")]
2 [assembly:XmlnsDefinition("自定义命名空间","已存在的命名空间2")]
posted @ 2015-04-30 14:45  试试手气  阅读(394)  评论(0编辑  收藏  举报