(转)silverlight中button不响应mouseleftbuttondown的原因
2009-12-14 23:03
459 查看
How to handle the MouseLeftButtonDown and MouseLeftButtonUp events of the Button control?
Have you ever noticed that the MouseLeftButtonDown and MouseLeftButtonUp events are not fired when a Silverlight button is clicked? The reason for this is that the button handles these two events itself by overriding the OnMouseLeftButtonDown and the OnMouseLeftButtonUp handlers. In the OnMouseLeftButtonDown override, the Click event is raised and the MouseLeftButtonDown event is marked as handled so it couldn't bubble in the visual tree. The OnMouseLeftButtonUp override also marks the MouseLeftButtonUp as handled.
This thing can be changed using the ClickMode property of the Button control. It has the following values - Hover, Press, Release. The default one is Pressed and we have already explained it. When we have ClickMode set to Release, the Click event will be raised in the OnMouseLeftButtonUp override and the MouseLeftButtonDown and MouseLeftButtonUp events will be handled inside the button again. If we set the ClickMode to Hover, the Click event will be raised with the MouseEnter event and we will also be able to use the mouse button events.
转自:http://www.silverlightshow.net/tips/Tip-How-to-handle-the-MouseLeftButtonDown-and-MouseLeftButtonUp-events-of-the-Button-control.aspx
Have you ever noticed that the MouseLeftButtonDown and MouseLeftButtonUp events are not fired when a Silverlight button is clicked? The reason for this is that the button handles these two events itself by overriding the OnMouseLeftButtonDown and the OnMouseLeftButtonUp handlers. In the OnMouseLeftButtonDown override, the Click event is raised and the MouseLeftButtonDown event is marked as handled so it couldn't bubble in the visual tree. The OnMouseLeftButtonUp override also marks the MouseLeftButtonUp as handled.
This thing can be changed using the ClickMode property of the Button control. It has the following values - Hover, Press, Release. The default one is Pressed and we have already explained it. When we have ClickMode set to Release, the Click event will be raised in the OnMouseLeftButtonUp override and the MouseLeftButtonDown and MouseLeftButtonUp events will be handled inside the button again. If we set the ClickMode to Hover, the Click event will be raised with the MouseEnter event and we will also be able to use the mouse button events.
转自:http://www.silverlightshow.net/tips/Tip-How-to-handle-the-MouseLeftButtonDown-and-MouseLeftButtonUp-events-of-the-Button-control.aspx
相关文章推荐
- 解决MouseLeftButtonDown在Grid等布局中无法响应事件 - [Silverlight开发]
- SilverLight学习笔记--如何解决Button不响应MouseLeftButtonDown与MouseLeftButtonUp事件的问题
- 如何解决Button不响应MouseLeftButtonDown与MouseLeftButtonUp事件的问题
- MouseLeftButtonDown event not working for Textbox in Silverlight
- wpf button的mouse(leftbutton)down/up,click事件不响应解决办法
- silverlight MouseLeftButtonDown事件无法触发
- silverlight MouseLeftButtonDown事件总是无法触发
- silverlight中button无法触发MouseLeftButtonDown等事件
- wpf button的mouse(leftbutton)down/up,click事件不响应解决办法
- wpf button的mouse(leftbutton)down/up,click事件不响应解决办法
- silverlight MouseLeftButtonDown事件总是无法触发
- silverlight MouseLeftButtonDown无法触发解决办法
- Button中MouseLeftButtonDown和MouseLeftButtonUp事件无法触发的解决方案
- 如何在Slider中使用MouseLeftButtonDown事件
- 错误:“ResourceDictionary”根元素需要 x:Class 特性来支持 XAML 文件中的事件处理程序。请移除 MouseLeftButtonDown 事件的事件处理程序.
- Button中 MouseLeftButtonDown和MouseLeftButtonUp 事件无法触发的解决方案 (转)
- 错误:“ResourceDictionary”根元素需要 x:Class 特性来支持 XAML 文件中的事件处理程序。请移除 MouseLeftButtonDown 事件的事件处理程序.
- MouseLeftButtonDown 事件不触发
- PreviewMouseLeftButtonDown 与 MouseLeftButtonDown
- Unity3D 中鼠标按下时OnMouseDown()、Input.GetMouseButtonDown()和EventType.MouseDown的响应验证