title: Binding chart LegendItem checkbox to series visibility in WPF in C# codebehind
body: <p>I have multiple column series chart getting generated in C#. I am further trying to get the legend for this chart with the checkboxes. Such that the chart displays the column series for only legend items that are checked. </p>
  
  <p>I need to do this in C# code behind and not in HTML. 
  I have the below existing code that creates the multiple dynamic column series -</p>
  
  <pre><code>foreach (KeyValuePair&lt;int, string&gt; item in list)
  {
    foreach (System.Data.DataRow dRow in dtTable.Rows)
    {
        &lt;formation of listSource&gt;
    }
  
    ColumnSeries ser = new ColumnSeries { Title = item.Value, IndependentValueBinding = new Binding("Key"), DependentValueBinding = new Binding("Value") };
            ser.ItemsSource = null;
            ser.ItemsSource = listSource;
            ser.DataPointStyle = columnStyleBrown;
            mcChart.Series.Add(ser);
            i++;
        }
  }
  </code></pre>
  
  <p>And I further want to add something to -</p>
  
  <p>ser.LegendItemStyle =</p>
  
  <p>So I need to know how to create a legend style with the check boxes in c#. </p>
  
  <p>There can be 2 ways of achieving this- </p>
  
  <ol>
  <li>Either by modifying the existing legend to contain check boxes also (preferred)</li>
  <li>Or to create a new legend altogether</li>
  </ol>
  
  <p>Can anyone please help?</p>
  
  <p>Thanks in advance!</p>