[RESOLVED] MouseDown doesnt work
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: [RESOLVED] MouseDown doesnt work

  1. #1
    Join Date
    Sep 2005
    Location
    Cracow, Poland
    Posts
    345

    [RESOLVED] MouseDown doesnt work

    I have the following code snippet:

    Code:
    <StackPanel TextBlock.FontWeight="Bold" MouseDown="StackPanel_MouseDown">
            <Label Name="label">dasdas</Label>
            <Button MouseDown="Button_MouseDown">
                <Rectangle Fill="Honeydew" Height="50" Width="200"></Rectangle>
            </Button>
        </StackPanel>
    Everything works for right clicks. However left clicks issue some strange behavior: left clicking in the area of the button (regardless of whether I`m clicking within or outside rectangle) results in no events being fired at all. Clicking outside the button (eg. in the "label") results in event "StackPanel_MouseDown" being fired (so it`s correct).

    Why does button "swallow" this event?

  2. #2
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: MouseDown doesnt work

    There is also PreviewMouseDown attached event, maybe you could try this one.
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

  3. #3
    Arjay's Avatar
    Arjay is online now Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,486

    Re: MouseDown doesnt work

    Bind to the Click event instead of MouseDown.

    That way, the button will be clicked if the user doesn't use the mouse to press the button (like pressing enter when the button has focus).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center