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?
- Kenichi Kobayashi asked 4 years ago
- You must login to post comments
When I try this I get the following exception
- Tore Munch answered 2 years ago
- You must login to post comments
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
- Andrew Burnett-Thompson answered 4 years ago
- You must login to post comments
Please login first to submit.