WPF学习笔记——XAML基础

 1处含义:

x:Class:
用来创建一个partial的class, 比如默认生成的x:Class="WPFDEMO.MainWindow", 会自动生成一个MainWindow的partial class,同时在project自动创建的MainWindow.cs partial class构造函数中,会调用一个InitializeComponent()
2,3,4,5处含义:

在XAML语法规则中,“xmlns”是属于强制关键字,被用来声明一个命名空间。其语法结构为“xmlns:”+“命名空间前缀名”,而对于默认命名空间,无需定义命名空间前缀名。

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"

以上四个命名空间是Visual Studio 11创建默认项目时自动生成的,其中分别映射了实例化一个Silverlight或Windows 8空白页面所需要的公共类库。

6 处含义:

表示可引用在同一程序集的内容

7处含义:

命名空间mc是跟兼容性有关的,mc:Ignorable="d"的意思就是告诉编辑器(vs)在项目运行时忽略命名空间d设置的大小。

属性命名

<Button Content="123" Height="100" Width="55" ></Button>

<Button  Height="100" Width="55" >
<Button.Content>321</Button.Content>
</Button>  

两种方式

附加属性

 事件

 

 xaml代码
<Button Name="button" Content="Button" Width="75" Height="20" Click="button_Click"/>
cs代码
private
void button_Click(object sender, RoutedEventArgs e) { }

猜你喜欢

转载自www.cnblogs.com/anyihen/p/12907200.html
今日推荐