I'm trying to convert the c # code of a sample code to vb.net but I could with the following line of code. it is an event, delegate. but I can not build a functional structure. someone could help me? thanks
Ellipse node = new Ellipse();
node.Style = nodeStyle;
node.MouseEnter += delegate(object sender, MouseEventArgs e) {
if (selectedNode == null)
node.BeginStoryboard((Storyboard)FindResource("NodeFadeIn"));
};
node.MouseLeave += delegate(object sender, MouseEventArgs e) {
if (selectedNode == null)
node.BeginStoryboard((Storyboard)FindResource("NodeFadeOut"));
};
node.PreviewMouseDown += delegate(object sender, MouseButtonEventArgs e) {
e.Handled = true;
selectedNode = (Ellipse)sender;
};
You need to use the AddHandler keyword in VB.NET to subscribe event handlers. In VS2010, an anonymous method can be substituted with a lambda, like this:
AddHandler node.MouseEnter, _
Sub()
If node Is Nothing Then
node.BeginStoryboard(DirectCast(FindResource("NodeFadeIn"), System.Windows.Media.Animation.Storyboard))
End If
End Sub
In VS2008 and earlier you'll need to write a little private method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.