9
我有以下XAML爲什麼e.Handled = true不工作?
<StackPanel MouseEnter="StackPanel_MouseEnter" Height="130" Background="Blue">
<Grid MouseEnter="Grid_MouseEnter" Height="60" Background="Red" >
<Button MouseEnter="Button_MouseEnter" Height="20"/>
</Grid>
</StackPanel>
在後面的代碼我這樣做
private void StackPanel_MouseEnter(object sender, MouseEventArgs e)
{
}
private void Grid_MouseEnter(object sender, MouseEventArgs e)
{
e.Handled = true;
}
private void Button_MouseEnter(object sender, MouseEventArgs e)
{
e.Handled = true;
}
現在,即使我鼠標移到Button
並設置e.Handled = true
的Grid
和StackPanel
事件分別被稱爲。爲什麼?我應該怎麼做才能阻止路由事件冒泡?
關於您的用戶名中的提案,我第二個議案! – Qwertie 2011-06-09 17:49:21