如何在单击子元素时阻止父事件

时间:2014-08-09 22:09:33

标签: c# wpf windows-phone-7 windows-phone-8

例如,当我点击按钮时也会启动网格事件。我怎么能避免它?

<Grid Tap="Grid_Tap">
    <Button Click="btn_Click" />
</Grid>

1 个答案:

答案 0 :(得分:4)

设置e.Handled = true;在按钮的处理程序

void Button_Click_1(object sender, RoutedEventArgs e)
    {
        //Handler code here
        e.Handled = true;
    }

Handled