A small pit of WPF control events ...

Source: Internet
Author: User

Recently want to determine the Slider is a mouse click and change the value, or the program internal code changes the value of the mouse to find various events such as MouseDown, MouseUp, MouseLeftButtonDown What, there is no response, is helpless ...

Searching for some of the controls in WPF will give some events to Handled themselves, resulting in the addition of events between US invalid ...

However, you can add an event to a child element by calling the AddHandler method on the parent element.

This method has two overloads, and the main thing here is to use this overloaded parameter:

 Public void AddHandler (    RoutedEvent RoutedEvent,    Delegate handler,    bool  handledEventsToo) 

The first is the type of event to be processed, the second is the event-handling method, and the third parameter is critical, because the event is called one-by-one, and it is likely that the Handled property is set to true to indicate that the event no longer needs to be handled by another processing method, but when this argument is passed to true , the event handling method bound here will no longer be restricted by the Handled attribute, and can still be called, so the rest is what to do.

msdn:https://msdn.microsoft.com/zh-cn/library/ms598899 (v=vs.100). aspx

A small pit of WPF control events ...

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.