Hello ALL,
While converting a c# code to vb i am facing a problem in converting a line of code.
The c# code is
private void Button_Loaded(object sender, RoutedEventArgs e)
{
((Button)sender).AddHandler(Button.MouseLeftButtonDownEvent,
new MouseButtonEventHandler(Button_MouseLeftButtonDown), true);
((Button)sender).AddHandler(Button.MouseLeftButtonUpEvent,
new MouseButtonEventHandler(Button_MouseLeftButtonUp), true);
((Button)sender).MouseMove += new MouseEventHandler(Button_MouseMove);
}
while i am able to get the Button.MouseLeftButtonDownEvent and Button.MouseLeftButtonUpEvent events i am not able to get the MouseMove event,
the converted code is something like this..
Private Sub Button_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
DirectCast(sender, Button).AddHandler(Button.MouseLeftButtonDownEvent, New MouseButtonEventHandler(AddressOf Button_MouseLeftButtonDown), True)
DirectCast(sender, Button).AddHandler(Button.MouseLeftButtonUpEvent, New MouseButtonEventHandler(AddressOf Button_MouseLeftButtonUp), True)
DirectCast(sender, Button).MouseMove += New MouseEventHandler(AddressOf Button_MouseMove)
End Sub
But the DirectCast(sender,Button).MouseMove does not work it throws an error stating
MouseMove is an event and cannot be called directly use an Raiseevent to raise the event.
What is the problem here? and how can i fix this?
Looking forward to your answer...
Thanks in advance.