Many years ago, SciChart tech support provided me with code for a RollerMarkerHelper class. I implemented this in VB.net, but I’ve attached a C# version which I just created using an automated translator. This code takes as arguments a RenderableSeries and a style template. I used this, along with a very simple style template such as the one shown below, so that I could display a gray circle over whatever point the cursor was over. (This is useful in my particular application.)
But I’m implementing a new application in C# using the MVVM approach (e.g., LineRenderableSeriesViewModel). How can I modify the RollerMarkerHelper class to handle this, or is there another approach I should use?
<ControlTemplate x:Key="SpectrumRolloverMarkerTemplate">
<Ellipse Width="7" Height="7" Fill="SlateGray" Stroke="SlateGray" StrokeThickness="1" />
</ControlTemplate>
- yefchak asked 3 months ago
- You must login to post comments
Hi there,
So you can apply a style, control template or whatever you like to a RolloverModifier in SciChart WPF when using the MVVM API
Following our guide in Worked Example – Style a Series in MVVM
When you declare a style in XAML like this:
<Style TargetType="s:FastLineRenderableSeries" x:Key="LineSeriesStyle0">
<Setter Property="StrokeDashArray" Value="5 5"/>
<Setter Property="StrokeThickness" Value="4"/>
<Setter Property="Stroke" Value="Orange"/>
<Setter Property="SelectedSeriesStyle">
<Setter.Value>
<Style TargetType="s:FastLineRenderableSeries">
<Setter Property="StrokeDashArray" Value="5 5"/>
<Setter Property="StrokeThickness" Value="3"/>
<Setter Property="Stroke" Value="White"/>
</Style>
</Setter.Value>
</Setter>
</Style>
you can then apply that style in the viewmodel by setting the StyleKey property of LineRenderableSeriesViewModel, e.g.
public class HelloSciChartWorldViewModel : INotifyPropertyChanged
{
private readonly ObservableCollection<IRenderableSeriesViewModel> _seriesViewModels = new ObservableCollection<IRenderableSeriesViewModel>();
public event PropertyChangedEventHandler PropertyChanged;
public HelloSciChartWorldViewModel()
{
var xyData = new XyDataSeries<double, double>();
for (int i = 0; i < 100; i++)
{
xyData.Append(i, Math.Sin(i * 0.2));
}
SeriesViewModels.Add(new LineRenderableSeriesViewModel()
{
DataSeries = xyData,
// Set the StyleKey equal to the x:Key in XAML
StyleKey = "LineSeriesStyle0"
});
}
public ObservableCollection<IRenderableSeriesViewModel> SeriesViewModels
{
get { return _seriesViewModels; }
}
protected virtual void OnPropertyChanged(string propertyName)
{
var handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Using this technique you should be able to apply the control template to the FastLineRenderableSeries.RolloverMarkerTemplate property via its style in XAML
Let me know if this helps
- Andrew Burnett-Thompson answered 3 months ago
- You must login to post comments
Please login first to submit.

