>I have a WPF Canvas with some Ellipse objects on it (displayed as circles). Each circle is from a collection class instance which is actually a custom hole pattern class. Each pattern has a certain number of circles, and each circle then gets added to the canvas using an iteration over the collection using the code below.
>
>So, the canvas is populated with a bunch of circles and each circle belongs to a certain pattern instance. You can see a screenshot here:
http://twitpic.com/1f2ci/full>
>Now I want to add the ability to click on a circle on the canvas, and be able to determine the collection it belongs to, so that I can then do some more work on the selected pattern to which that circle belongs.
>
>
>public void DrawHoles()
>{
> // Iterate over each HolePattern in the HolePatterns collection...
> foreach (HolePattern HolePattern in HolePatterns)
> {
> // Now iterate over each Hole in the HoleList of the current HolePattern...
> foreach (Hole Hole in HolePattern.HoleList)
> {
> Hole.CanvasX = SketchX0 + (Hole.AbsX * _ZoomScale);
> Hole.CanvasY = SketchY0 - (Hole.AbsY * _ZoomScale);
> canvas1.Children.Add(Hole.HoleEntity);
> }
> }
>}
>
Are you asking how to find the collection, or how to handle the click.
For finding the collection I would probably store it as a property of the hole.
For the click I would use the PreviewMouseDown event on the ellipse.