Fazer uma PerguntaFazer uma Pergunta
 

RespondidoWhat's wrong with the left mouse button in beta2?

  • quinta-feira, 25 de maio de 2006 19:42Konstantin GonikmanModeradorMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

    That's weird, MouseDown and MouseLeftButtonDown are not working here. Left-clicking on the button, test1 and test2 event handlers are not hit. There's no problem with the right mouse button.

    <Button  MouseDown="test1" MouseLeftButtonDown="test2" MouseRightButtonDown="test3" />

    A bug?.. Can somebody repro this?

Respostas

Todas as Respostas

  • quinta-feira, 25 de maio de 2006 20:16csammis Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
    Button elements capture the left mouse down event via the Click event  (or right mouse down, if the system is configured for "right button" clicks), which is probably what's stopping your explicit MouseDown handlers.
  • quinta-feira, 25 de maio de 2006 20:20Konstantin GonikmanModeradorMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
    Click event works as expected. But why should Click event hinder a MouseDown event?
  • quinta-feira, 25 de maio de 2006 20:23Konstantin GonikmanModeradorMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

    Never mind, I've found an explanation on msdn:

     

    Working Around Event Suppression by Controls

    One scenario where preview events are used is for input events and controls. Sometimes, the creator of the control might wish to suppress a certain event from originating from their control, perhaps to substitute a component-defined event that carries more information or implies a more specific behavior. For instance, a Windows Presentation Foundation (formerly code-named "Avalon") Button suppresses normal MouseLeftButtonDown bubbling events in favor of a Click event. If other elements towards the root of your application still wanted an opportunity that event, one alternative is to handle even routed events. But a simpler way is to change the routing direction you handle to be the Preview equivalent PreviewMouseLeftButtonDown.

  • quinta-feira, 25 de maio de 2006 20:27LesterLobo - MSFTModeradorMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Respondido
    try the PreviewMouseLeftButtonDown