ScrollViewer 不会触发 KeyUp 事件
我正在使用 Syncfusion 的 TreeViewAdv 控件。我向其附加了一个 KeypUp 事件处理程序,它按预期工作。每当我释放按键时就会触发该事件。但是,一旦我将其包装在 ScrollViewer 中,该事件就不会被触发。我必须将事件处理程序移至 ScrollViewer 本身才能捕获事件。我还检查了 PreviewKeyUp 事件,在 ScrollViewer 中它被触发并且 Handled 为 false。但是 TreeViewAdv 的 PreviewKeyUp 根本没有被触发。
我尝试用 StackPanel 替换 ScrollViewer,一切都很好。因此,ScrollViewer 似乎停止了向其内容传播事件。如何在 ScrollViewer 中处理事件?
I am using Syncfusion's TreeViewAdv control. I attach a KeypUp event handler to it and it worked as expected. The event is fired whenever I released a key. However, once I wrap it in a ScrollViewer, the event is not fired. I have to move the event handler up to the ScrollViewer itself to catch the event. I aslo checked the PreviewKeyUp event, at the ScrollViewer it is fired and the Handled is false. But the PreviewKeyUp for TreeViewAdv is not fired at all.
I try to replace the ScrollViewer with a StackPanel and everything is fine. So it seems that the ScrollViewer stops event propagation to its content. How can I get the event handled within the ScrollViewer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以看到,只有当您通过鼠标选择项目然后尝试捕获 KeyUp 和 KeyDown 事件时才会发生这种情况。当您仅通过键盘导航项目(例如使用 Tab 键)时,这些事件会正确触发。
这是 TreeViewAdv 控件中的已知问题,Syncfusion 已修复此问题。他们承诺类似的修复将包含在计划于 2009 年 1 月结束的即将发布的 2010 年第 1 版中。
作为解决方法,您可以使用此代码片段来接收事件通知。
C# 中的事件处理程序
private void TreeViewItemAdv1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
TreeViewItemAdv item=(发送者为 TreeViewItemAdv);
如果(项目!= null)
{
item.Focus();
}
谢谢
,
马丹
I could see that this is happening only when you select item through mouse and then trying to catch KeyUp and KeyDown events. These events are firing properly when you navigate items through keyboard only such as using Tab Key.
This is known issue in TreeViewAdv control and Syncfusion fixed this. They promised like fix will be included in their forth coming release Vol1 2010 which is scheduled on end of Jan 2009.
As a workaround, you can use this code snippet to receive the event notification.
<Syncfusion:TreeViewAdv.Resources>
<Style TargetType="{x:Type syncfusion:TreeViewItemAdv}">
<EventSetter Event="MouseLeftButtonUp"
Handler="TreeViewItemAdv1_MouseLeftButtonUp"/>
</Style>
</Syncfusion:TreeViewAdv.Resources>
Event handler in C#
private void TreeViewItemAdv1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
TreeViewItemAdv item= (sender as TreeViewItemAdv);
If(item != null)
{
item.Focus();
}
}
Thanks,
Madhan