I’m adding ellipses in a long for cycle (more than 100 is added), and I want to know a property added in the same for cycle on click event.
inside the for cycle:
var ellipse = new Ellipse();
ellipse.myValue=12; // this needs to be editable and working
....
ellipse.MouseDown += ellipseClick;
canvas2.Children.Add(ellipse);
Here is the listener:
private void ellipseClick(object sender, MouseButtonEventArgs e)
{
if(myValue==12)
....
}
of course it is a bit more complicated, I’d need a pointer or 3 int values for every Ellipse.
I don’t want to go on every Ellipse and check the click position and if it is the same as the sender.
I can’t extend the Ellipse class, because it is sealed, and I can’t rewrite code in the Ellipse class.
You could use the
Tag-property, to store additional information.I hope that is what you are asking for, but according to your comment on my question, you just want to store information with each ellipse.
You can create a struct or class that contains all the information you want and just set the
Tagto that class. It allows you to store about anything you want.