名称空间
xmlns
作用是引入名称空间。在xaml中使用某个类型的功能,与在c#代码中类似,需要添加库文件,再引入该类所在的命名空间。
- 命名空间的别名
xmlns[:别名]=“xxxx”, 就是给引号内的名称空间取别名,好处是 同一个引用可以有多个别名,使用方便 - 默认命名空间
没有别名,就是默认的命名空间,只能有一个,该命名空间内的类型可以直接使用不需要加前缀 - 特殊的名称空间
http://schemas.microsoft.com/winfx/2006/xaml/presentation,是硬编码,代表一组应用和命名空间,与控件和界面元素,布局等相关
http://schemas.microsoft.com/winfx/2006/xaml ,硬编码,代表一组引用和名称空间,与xaml 语言编译相关,x:Class 指令是将该Window 自动编译成类,类的名称XamlTest.MainWindow。
<Window x:Class="XamlTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:XamlTest"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
</Grid>
</Window>