title: DataTemplate for RolloverModifier on SciChart when RenderableSeries is bound to MVVM
body: <p>I am trying to customise the appearance of the <code>RolloverModifier</code> tooltips that appear on a SciChart Line Chart, using a <code>DataTemplate</code> (combined with the <code>TooltipTemplate</code> attribute of the <code>RolloverModifier</code>, but can't figure it out.</p>
  
  <p>Here is my <code>DataTemplate</code> which I've made as simple as possible just to get it working.</p>
  
  <pre><code>&lt;DataTemplate x:Key="ChartToolTipTemplate" DataType="{x:Type s:SeriesInfo}"&gt;
     &lt;TextBlock Text="Hello" /&gt;
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p><strong>What I've tried so far:</strong></p>
  
  <p>First:</p>
  
  <pre><code>&lt;s:RolloverModifier x:Name="RolloverModifier" TooltipTemplate="{StaticResource ChartToolTipTemplate}"&gt;
  </code></pre>
  
  <p>but I get the error:</p>
  
  <blockquote>
    <p>Unable to cast object of type 'SciChart.Charting.ChartModifiers.RolloverModifier' to type 'SciChart.Charting.Visuals.RenderableSeries.BaseRenderableSeries'.</p>
  </blockquote>
  
  <p>From research online, it appears what I should be doing is:</p>
  
  <pre><code>&lt;s:SciChartSurface.RenderableSeries&gt;
      &lt;s:FastLineRenderableSeries  s:TooltipModifier.TooltipTemplate="{StaticResource TooltipTemplate}" 
                                  s:TooltipModifier.IncludeSeries="True"
                                  s:SeriesValueModifier.IncludeSeries="False"/&gt;
  &lt;/s:SciChartSurface.RenderableSeries&gt;
  </code></pre>
  
  <p>However, this is no good to me as my <code>RenderableSeries</code> is bound to an <code>ObservableCollection&lt;IRenderableSeries&gt;</code> in my ViewModel.</p>
  
  <pre><code>&lt;s:SciChartSurface
      x:Name="SciChart"
      Grid.Column="0"
      Annotations="{Binding Annotations}"
      GridLinesPanelStyle="{StaticResource GridLinesPanelStyle}"
      RenderableSeries="{Binding ChartSeries}"
      Style="{StaticResource SurfaceStyle}"&gt;
  </code></pre>
  
  <p>A suggestion on a similar question to this was to use <code>ObservableCollection&lt;IRenderableSeriesViewModel&gt;</code> and set the style in the ViewModel as per this page in the documentation: <a href="https://www.scichart.com/documentation/v4.x/Worked%20Example%20-%20Bind%20Tooltip%20Templates%20or%20Attached%20Properties%20in%20MVVM.html" rel="nofollow noreferrer">Bind Tooltip Templates or Attached Properties in MVVM</a>, but I couldn't figure out how to convert my <code>IRenderableSeries</code> to a <code>LineRenderableSeriesViewModel</code> and ended up with a blank chart.</p>
  
  <p>Another suggestion in this similar question (<a href="https://stackoverflow.com/questions/43329977/scichart-custom-rollovermodifierlabel-for-multiple-dataseries-bound-from-code">SciChart: Custom RolloverModifierLabel for multiple DataSeries bound from code</a> was to use an Implicit Style, so I added</p>
  
  <pre><code>    &lt;s:SciChartSurface.Resources&gt;
          &lt;Style TargetType="s:BaseRenderableSeries"&gt;
              &lt;Setter Property="s:RolloverModifier.TooltipTemplate" Value="{StaticResource ChartToolTipTemplate}" /&gt;
              &lt;Setter Property="s:RolloverModifier.IncludeSeries" Value="True" /&gt;
              &lt;Setter Property="s:RolloverModifier.IsEnabled" Value="True" /&gt;
              &lt;Setter Property="FontSize" Value="30" /&gt;
          &lt;/Style&gt;
      &lt;/s:SciChartSurface.Resources&gt;
  </code></pre>
  
  <p>And kept the </p>
  
  <pre><code>    &lt;s:SciChartSurface.ChartModifier&gt;
          &lt;s:ModifierGroup&gt;
              &lt;s:LegendModifier
                  x:Name="LegendModifier"
                  Margin="10"
                  HorizontalAlignment="Right"
                  LegendTemplate="{StaticResource LegendTemplate}"
                  Orientation="Horizontal"
                  ShowLegend="{Binding ShowLegend}"
                  ShowVisibilityCheckboxes="False" /&gt;
                  &lt;s:RolloverModifier x:Name="RolloverModifier" /&gt;
              &lt;s:SeriesSelectionModifier&gt;
                  &lt;s:SeriesSelectionModifier.SelectedSeriesStyle&gt;
                      &lt;Style TargetType="s:BaseRenderableSeries"&gt;
                          &lt;Setter Property="Stroke" Value="DeepPink" /&gt;
                          &lt;Setter Property="StrokeThickness" Value="3" /&gt;
                      &lt;/Style&gt;
                  &lt;/s:SeriesSelectionModifier.SelectedSeriesStyle&gt;
              &lt;/s:SeriesSelectionModifier&gt;
          &lt;/s:ModifierGroup&gt;
      &lt;/s:SciChartSurface.ChartModifier&gt;
  </code></pre>
  
  <p>But the style has no effect at all on the tooltips (even the <code>FontSize</code> bit which I just put in to check if it was even working). Removing that line removes the tooltips completely.</p>