SliverLight4的路由事件,是一种冒泡向上的事件
XAML:
<StackPanel Background="Green" Height="176" Name="stackPanel1" Width="422" MouseLeftButtonDown="button1_MouseLeftButtonDown">
<Canvas Background="Yellow" Height="136" Name="canvas1" Width="226" MouseLeftButtonDown="button1_MouseLeftButtonDown">
</Canvas>
</StackPanel>
XAML.CS:
private void button1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if(e.OriginalSource is StackPanel)
{
MessageBox.Show("StackPanel");
}
else if(e.OriginalSource is Canvas)
{
MessageBox.Show("Canvas");
}
}