disable event-bubbling c# wpf

Posted by Ruben on Stack Overflow See other posts from Stack Overflow or by Ruben
Published on 2010-03-23T07:53:20Z Indexed on 2010/03/23 8:03 UTC
Read the original article Hit count: 406

Filed under:
|
|
|

Hi, I'm having the following problem:

When I got two labels into each other:

<Label x:Name="First" MouseUp="Label_MouseUp">
    <Label x:Name="Second" MouseUp="Label_MouseUp_1">This is a label into another label</Label>
</Label>

And the following code:

private void Label_MouseUp(object sender, MouseButtonEventArgs e)
{
    Console.WriteLine("Do NOT show me");
}

private void Label_MouseUp_1(object sender, MouseButtonEventArgs e)
{
    Console.WriteLine("Show me");
}

When i click "Second", I want it to trigger only "Label_MouseUp_1". But in my console i get:

Show me
Do NOT show me

Is there a way to turn off the bubbling events?

(also, "First" has to be clickable, so removing the event there doesn't solve the problem)

Thnx

© Stack Overflow or respective owner

Related posts about disable

Related posts about event-bubbling