title: WPF Toolkit Chart: refresh axis label visibility when binding label visibility to a converter
body: <p>I have a WPF Toolkit Line Chart where I'd like to control the number of CategoryAxis (x-axis) labels that are shown. If the number of labels exceeds a certain value, I want to show only every <em>nth</em> label to keep things clear.</p>
  
  <p>To achieve this, I've created an IValueConverter and bound it to the Visibility property of the AxisLabelStyle. The relevant XAML looks like this (note I'm also rotating the labels, that part is working fine):</p>
  
  <pre><code>&lt;chartingToolkit:Chart.Resources&gt;
    &lt;app:HideConverter x:Key="HideConverter1" /&gt;                            
  &lt;/chartingToolkit:Chart.Resources&gt;
  ...
  ...
  &lt;chartingToolkit:CategoryAxis Orientation="X" Title="" ShowGridLines="False"&gt;
      &lt;chartingToolkit:CategoryAxis.AxisLabelStyle&gt;
        &lt;Style TargetType="chartingToolkit:AxisLabel"&gt;
          &lt;Setter Property="Template"&gt;
            &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="chartingToolkit:AxisLabel"&gt;
                &lt;Canvas Height="55"&gt;
                  &lt;Label Content="{TemplateBinding FormattedContent}" 
                         FontSize="12" Foreground="Black"                                                                
                         Visibility="{Binding Converter={StaticResource HideConverter1}}"&gt;
                  &lt;Label.RenderTransform&gt;
                    &lt;TransformGroup&gt;
                      &lt;RotateTransform Angle="-45" /&gt;
                      &lt;TranslateTransform X="-50" Y="0"/&gt;
                    &lt;/TransformGroup&gt;
                  &lt;/Label.RenderTransform&gt;
                  &lt;Label.RenderTransformOrigin&gt;
                    &lt;Point&gt;1.0, 1.0&lt;/Point&gt;
                  &lt;/Label.RenderTransformOrigin&gt;
                &lt;/Label&gt;
              &lt;/Canvas&gt;
            &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
        &lt;/Setter&gt;
      &lt;/Style&gt;
    &lt;/chartingToolkit:CategoryAxis.AxisLabelStyle&gt;
  </code></pre>
  
  <p></p>
  
  <p>And here's the C# code for the converter:</p>
  
  <pre><code>public class HideConverter:IValueConverter
  {
      private int hitCount = 0;
  
      public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          hitCount++;
  
          if (hitCount % INTERVAL_VALUE == 0.0)
          {
              return Visibility.Visible;
          }
          else
          {
              return Visibility.Hidden;
          }            
      }
  
      public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          throw new NotImplementedException();
      }
  }
  </code></pre>
  
  <p>So if I set INTERVAL_VALUE = 20, I get every 20th label. When the graph is first displayed, it <strong>works perfectly</strong>. </p>
  
  <p>The problem is that when I update the INTERVAL_VALUE in my code, I cannot get the CategoryAxis to re-draw itself. </p>
  
  <p>I've tried invalidating the entire chart to force it to be re-drawn, but there is no effect. Basically the converter code is only called when the chart is first rendered and never called again, so changing the value of INTERVAL_VALUE has no effect.</p>
  
  <p>Any suggestions appreciated.</p>