0

this is my first time here so i'll try to explain as best as i can.

I have a dictionary of PointCollections/String and i need to loop as many times as there is item in it. It's pretty basic so i managed to do it and create a checkbox for each item but i'd like to set an action to the checkbox when it's checked and unchecked, here's my code with the problem in //

Thanks

foreach (var key in instantCurves._curveList)
        {
            CheckBox series = new CheckBox();
            series.Content = key.Value;
            //series.Checked = affMatchingCurve(key.Value);
            setCurve(key.Key, key.Value);

            SeriesHolder.Children.Add(series);
        }
Hugo LM
  • 1
  • 1
  • 1

1 Answers1

0

You can attach event handlers in code behind by means of the += operator:

foreach (var key in instantCurves._curveList)
{
    CheckBox series = new CheckBox();
    series.Content = key.Value;
    series.Checked += SeriesChecked;
    series.Unchecked += SeriesUnchecked;
    setCurve(key.Key, key.Value);
    SeriesHolder.Children.Add(series);
}

The Checked and Unchecked event handlers:

private void SeriesChecked(object sender, RoutedEventArgs e)
{
}

private void SeriesUnchecked(object sender, RoutedEventArgs e)
{
}

You may also use the same method for both events.

Clemens
  • 123,504
  • 12
  • 155
  • 268
AJAY KUMAR
  • 77
  • 7