首页 > 代码库 > CLR事件与路由事件在XAML代码中应用时的区别

CLR事件与路由事件在XAML代码中应用时的区别

 

<Window x:Class="Demo_window.Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Demo_window" 
Title="Window2" Height="300" Width="300"
>

 

<Grid x:Name="grid_1">

<Grid x:Name="grid_2" local:Student.Test="ddd">
<Grid x:Name="grid_3" >
<StackPanel x:Name="sp_1" >
<!--Button.Click="Button_Click"是安装方式,当前控件安装了Button.Click事件侦听器,当该事件被激发时,会调用Button.Click事件的处理方法-->
<!--Click="Button_Click"是button1控件自身带的CLR事件进行订阅{调用CLR事件的add访问器}-->
<Button x:Name="button1" Width="80" Height="80" Button.Click="Button_Click" Click="Button_Click"/>

</StackPanel>
</Grid>
</Grid>
</Grid>

 

</Window>

CLR事件与路由事件在XAML代码中应用时的区别