Click here to Skip to main content
16,017,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 19-Aug-16 4:03am

1 solution

As the error message says, you need to set the RoutedEvent property of the MouseButtonEventArgs to the routed event you're raising.

Something like this should work:
C#
e = new MouseButtonEventArgs(InputManager.Current.PrimaryMouseDevice, e.Timestamp, MouseButton.Left);
e.RoutedEvent = UIElement.MouseLeftButtonDownEvent;
currentDesigner.OnMouseLeftButtonDown(sender as AnnContainer, e);
 
Share this answer
 
Comments
Member 11559270 20-Aug-16 0:50am    
Thank you Richard Deeming, Its working perfect

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900