Adding events to control arrays within a user control
<p>I have a user control with a stack panel on it and the ability to dynamically add checkboxes to that stack panel, what i would like to do is add a RoutedEventHandler for these new Checkboxes but I'm not too sure how its done. The usual way I add these handlers to static controls is:</p>

<p>public event RoutedEventHandler CheckboxClicked
{</p>

<pre><code> add { CheckBox.Checked += value; }
 remove { Checkbox.Checked -= value; }
</code></pre>

<p>}</p>

<p>with the dynamic list of controls I did this:</p>

<p>public event RoutedEventHandler CheckboxClicked
        {</p>

<pre><code>        add
        {
            foreach (CheckBox c in LayoutRoot.Children)
            {

                c.Checked += value;

            }
        }

        remove
        {

            foreach (CheckBox c in LayoutRoot.Children)
            {

                c.Checked -= value;

            }
        }

    }
</code></pre>

<p>however, this does NOT work, so if anyone can help, i'll really appreciate it,</p>

<p>thanks</p>
