Hi everyone,
I have come across a very unusual problem trying to animate dynamically created rectangles in my VB.NET 3.5/WPF project. I create a series of rectangles based on the number of columns and rows a user inputs. That is no problem, they are all created just fine. I then set each rectangle the event handler for MouseLeftButtonDown:
AddHandler
Again, that works fine, when I click on a rectangle that event is fired and I can pull the name of the rectangle selected. But when I add animation to it, the rectangle doesn't animate, the entire form animates! if I maximize the form, it doesn't run the animation on the form, but if it is free floating, the form actually runs the animation...not the rectangle. But, as I said, when I check the name of the object (sender)...it comes back with the name of the rectangle...not the form, so sender is being seen as the rectangle and not the form.
Any ideas as to why this happens?
My code is this:
strName = sender.Name
widthAnimation.From = 0
widthAnimation.To = 50
widthAnimation.Duration = TimeSpan.FromSeconds(2)
heightAnimation.From = 0
heightAnimation.To = 50
heightAnimation.Duration = TimeSpan.FromSeconds(2)
sender.fill =
BeginAnimation(sender.WidthProperty, widthAnimation)
BeginAnimation(sender.HeightProperty, heightAnimation)