title: Selecting an object on a WPF Canvas?
body: <p>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.</p>
  
  <p>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: <a href="http://twitpic.com/1f2ci/full" rel="nofollow noreferrer">http://twitpic.com/1f2ci/full</a></p>
  
  <p>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.</p>
  
  <pre><code>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...
          // This code adds the HoleEntity, HoleDecorator, and HoleLabel to the canvas
          foreach (Hole Hole in HolePattern.HoleList)
          {
  
              Hole.CanvasX = SketchX0 + (Hole.AbsX * _ZoomScale);
              Hole.CanvasY = SketchY0 - (Hole.AbsY * _ZoomScale);
              canvas1.Children.Add(Hole.HoleEntity);
          }
      }
  }
  </code></pre>