) Why does a button in Silverlight not respond to mouseleftbuttondown?

Source: Internet
Author: User

How to handle the mouseleftbuttondown and mouseleftbuttonup events of the button control?


Have you ever noticed thatMouseleftbuttondownAndMouseleftbuttonupEvents are not fired when a Silverlight button is clicked? The reason for this is that the button handles these two events itself by overridingOnmouseleftbuttondownAndOnmouseleftbuttonupHandlers. InOnmouseleftbuttondownOverride,ClickEvent is raised andMouseleftbuttondownEvent is marked as handled so it couldn't bubble in the visual tree.OnmouseleftbuttonupOverride also marksMouseleftbuttonupAs handled.

This thing can be changed usingClickmodeProperty of the button control. It has the following values-Hover, press, release. The default one isPressedAnd we have already explained it. When we have clickmode setRelease,ClickEvent will be raised inOnmouseleftbuttonupOverride andMouseleftbuttondownAndMouseleftbuttonupEvents will be handled inside the button again. If we setClickmodeToHover,ClickEvent will be raised withMouseenterEvent and we will also be able to use the mouse button events.


From: http://www.silverlightshow.net/tips/Tip-How-to-handle-the-MouseLeftButtonDown-and-MouseLeftButtonUp-events-of-the-Button-control.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.