App.xaml:顶级元素是 Application 它StartupUri属性指定启动页面,Class制定后置类
名称空间:xmlns
http://schemas.microsoft.com/winfx/2006/xaml/presentation 这个是WPF的核心名称空间 包含了所有WPF类
xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
这里使用了 x前缀
没有前缀 就是使用 xmlns
比如我们的 Application.Resources 就算使用xmlns名称空间
我们打开MainWindows
也可以看到xmlns和xmlns:x xmlns:d xmlns:mc 等等这些名称空间
然后下面有Grid Button这些标记 这些标记 没有前缀 就算使用xmlns名称空间
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” 这个为例,其实它就是System.Windows,System.Windows.Automation,System.Windows.Controls….等一系列命名空间的集合,是这个集合的【别名】,在浏览器输入这个网址有时候是不可访问的。如果自己定义类库的话,我把这个【别名】叫做张三也是可以的。微软建议,这个一般定义为公司网址,或者个人网址。
控件属性的两种形式
<Button x:Name="button" Content="FoxDevelop.com" HorizontalAlignment="Left" Margin="407,264,0,0" VerticalAlignment="Top" Width="75" Click="button_Click"/>
<Button Cursor="Arrow">
<Button.Name>button2</Button.Name>
<Button.Width>60</Button.Width>
<Button.Height>20</Button.Height>
<Button.Content>一起</Button.Content>
</Button>Code language: HTML, XML (xml)
Previous: 01-WPF理解和创建第一个WPF
Next: 03-MainWindow的布局设计