Silverlight Button MouseLeftButtonUp/Down Event

Last few days, I have been trying to use a Button as a drag and drop object in Silverlight 4, but the MouseLeftButtonUp and MouseLeftButtonDown event just won’t fire up no matter how I click on it. After some search, I found out that MouseLeftButtonUp and MouseLeftButtonDown event in Button is handle by Click event thus it won’t trigger MouseLeftButtonUp and MouseLeftButtonDown anymore.

One solution for this is to create an inherited Button class and override MouseLeftButtonUp and MouseLeftButtonDown event by setting Handled to false so that it won’t handle by Click event. While the other solution is to use other UIElement control instead of Button.

But I’m lazy to create a class just for this purpose and I need a Button control. After some search on MSDN, I found out that I can prevent Click event to handle MouseLeftButtonUp and MouseLeftButtonDown event by setting button’s ClickMode to Hover which was by default is Press. It’s work! With just a single line or a property set, I can enable back MouseLeftButtonUp and MouseLeftButtonDown event for button now.

Source: http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.buttonbase.onmouseleftbuttondown.aspx

by Ooi Keng Siang via Ooiks’s Blog

5 thoughts on “Silverlight Button MouseLeftButtonUp/Down Event

  1. Hey ,

    i am a user of your mousehunt autobot programme.
    Just wondering what do you mean by pause before kings reward?
    Secondly, is there an alarm when kings reward pops out to inform users?
    Thirdly, as the moushunt programme was changed, trap check time for each individual has changed. For exmaple, my trap check is at 1:30.2:30 ….6:30,7:30 and every 30 mins instead of the start of a new hour, 1:00,2:00….ect

    Please reply ASAP or drop me an email.

    regards,
    jason

    Like

  2. Hey ,

    i am a user of your mousehunt autobot programme.
    Just wondering what do you mean by pause before kings reward?
    Secondly, is there an alarm when kings reward pops out to inform users?
    Thirdly, as the moushunt programme was changed, trap check time for each individual has changed. For exmaple, my trap check is at 1:30.2:30 ….6:30,7:30 and every 30 mins instead of the start of a new hour, 1:00,2:00….ect

    Please reply ASAP or drop me an email.
    Thank you
    regards,
    jason

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s