举起活动的问题 [英] Problem in raising the event
问题描述
if(currentDesigner!= null)
{
e = new MouseButtonEventArgs(InputManager.Current.PrimaryMouseDevice,
e.Timestamp,
MouseButton.Left);
currentDesigner.OnMouseLeftButtonDown(发件人为AnnContainer,e);
}
在上面提到的代码中,我在最后一行得到一个例外(currentDesigner.OnMouseLeftButtonDown(发件人为AnnContainer,e);)
例外:每个routedeventargs都必须有一个与之关联的非空路由事件。
请尽快回复
我尝试了什么:
我试图让e.Handled = false但是它不起作用
if (currentDesigner != null)
{
e = new MouseButtonEventArgs(InputManager.Current.PrimaryMouseDevice,
e.Timestamp,
MouseButton.Left);
currentDesigner.OnMouseLeftButtonDown(sender as AnnContainer, e);
}
In above mentioned code i am getting an exception in last line(currentDesigner.OnMouseLeftButtonDown(sender as AnnContainer, e);)
Exception:Every routedeventargs must have a non-null routed event associated with it.
Please reply as soon as possible
What I have tried:
I try to make e.Handled=false but its not working
推荐答案
正如错误消息所示,您需要设置RoutedEvent
属性> MouseButtonEventArgs 到路由事件你是rais ing。
这样的事情应该有效:
As the error message says, you need to set theRoutedEvent
property of theMouseButtonEventArgs
to the routed event you're raising.
Something like this should work:
e = new MouseButtonEventArgs(InputManager.Current.PrimaryMouseDevice, e.Timestamp, MouseButton.Left);
e.RoutedEvent = UIElement.MouseLeftButtonDownEvent;
currentDesigner.OnMouseLeftButtonDown(sender as AnnContainer, e);
这篇关于举起活动的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!