Andrej
Andrej

Reputation: 11

Button does not click if I handle content's mousedown

I have this situation:

<Button MouseDown="Button_MouseDown" Click="Button_Click">
    <TextBlock MouseDown="Inner_MouseDown">Button</TextBlock>
</Button>

Method Inner_MouseDown is completely empty. .Handled is NOT set to true. But Button_Click is not executed. If I remove the MouseDown="Inner_MouseDown",button clicks without problems. Can anybody help me find out why handling MouseDown with no logic prevents button from click?

Thanks a lot.

Andrej

Upvotes: 0

Views: 469

Answers (2)

stone
stone

Reputation: 8662

My guess: It may be because Click == MouseDown + MouseUp within a small time interval, and when you break after the MouseDown, the MouseUp isn't processed until after the time interval has elapsed.

Upvotes: 0

Andrej
Andrej

Reputation: 11

OK, I found out something important. It seems that it works good until I add breakpoint to Inner_MouseDown method. If debugger stops there Click event is not raised. If I just remove the breakpoint it works allright. Same problem if I show messagebox in the Inner_MouseDown method. If I just increment some temp variable it works nice.

But this answers my question, why it does not work even if it should. Actually it works, problem is somewhere else.

Upvotes: 1

Related Questions