Pre loader

How to specify TooltipModifier.TooltipTemplate

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

I am doing SciChart development with MVVM.
I generate RenderableSeries with ViewModel, View uses Bind it and uses it.

TooltipModifier is used for tooltip display.
In this application, I want to customize and display the tooltip.

To customize using the TooltipTemplate of TooltipModifier,
It was described in the following URL.
In this method, TooltipModifier.TooltipTemplate is described in XAML in View resource.
Therefore, it is not possible to specify TooltipModifier.TooltipTemplate from ViewModel.

If you generate RenderableSeries with ViewModel,
How should I specify the TooltipTemplate?

Version
5.1.1.11473
  • You must to post comments
0
0

In the SciChart WPF Documentation there is a page for how to bind tooltip templates in MVVM

A lot of customers ask us how to style various attached properties used in SciChart in the MVVM API. For example, the given following attached properties, how do we convert this to the MVVM API?

<Grid>
      <Grid.Resources>
          <Style TargetType="s:FastLineRenderableSeries" x:Key="PropertyStyles">
              <Setter Property="s:TooltipModifier.TooltipTemplate" Value="{StaticResource TooltipTemplate}"/>
              <Setter Property="s:TooltipModifier.IncludeSeries" Value="True"/>
              <Setter Property="s:SeriesValueModifier.IncludeSeries" Value="False"/>
          </Style>
      </Grid.Resources>
      <s:SciChartSurface s:RenderableSeries="{Binding Series}">            
          <s:SciChartSurface.XAxis>
              <s:NumericAxis/>
          </s:SciChartSurface.XAxis>
          <s:SciChartSurface.YAxis>
              <s:NumericAxis/>
          </s:SciChartSurface.YAxis>
          <s:SciChartSurface.ChartModifier>
              <s:ModifierGroup>
                  <s:TooltipModifier/>
                  <s:SeriesSelectionModifier/>
              </s:ModifierGroup>
          </s:SciChartSurface.ChartModifier>
      </s:SciChartSurface>
  </Grid>
  

The solution is simple, to use our method of Styling the RenderableSeries presented in Worked Example – Style a Series in MVVM.

Simply declare the attached properties and tooltip templates in a style in your View.

public class MainViewModel : BindableObject
  {
          public MainViewModel()
          {
              Series = new ObservableCollection<IRenderableSeriesViewModel>();
              Series.Add(new LineRenderableSeriesViewModel()
              {
                  Stroke = Colors.Red,
                  DataSeries = ... // todo 
                  StyleKey = "PropertyStyles"
              });
          }
          public ObservableCollection<IRenderableSeriesViewModel> Series { get; private set; }
      }
  

Best regards,
Andrew

  • You must to post comments
0
0

When I try this I get the following exception

Images
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies