SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
I’m migrating from v3.1 to 6.5 but unsure how to deal with a custom renderable series that contains dependency props used by its overridden Draw() method. This is the class:
public class CustomXyScatterRenderableSeries : CustomRenderableSeries
{
// An example dependency prop:
public static readonly DependencyProperty RejectionLimitProperty = DependencyProperty.Register(
"RejectionLimit",
typeof(double?),
typeof(NuXyScatterRenderableSeries),
new PropertyMetadata(null, OnPropertyChangedGeneric));
protected override void Draw(...) ...
}
I have now created a renderable series view model to go with the custom renderable series:
public class CustomXyScatterRenderableSeriesViewModel : BaseRenderableSeriesViewModel
{
public override Type ViewType => typeof(CustomXyScatterRenderableSeries);
}
And in my window VM I have something like this, to programmatically create the chart series:
public ObservableCollection<IRenderableSeriesViewModel> SeriesCollection {get;} // Bound to the chart's 'RenderableSeries'
...
var vm = new CustomXyScatterRenderableSeriesViewModel()
{
StyleKey = "customSeriesStyle",
StrokeThickness = 1,
AntiAliasing = False,
...,
RejectionLimit = 123 // Obviously won't work!
}
SeriesCollection.Add(vm);
As per the above comment, how do I assign values to the RejectionLimit (and other dependency props)? I’m guessing that I’ll have to create a “RejectionLimit” property on my window VM, set this to 123 (or whatever), then bind this property to the custom renderable series dependency prop via the XAML style (created as per this article), e.g.:
<Style TargetType="CustomXyScatterRenderableSeries" x:Key="customSeriesStyle"
BasedOn="{StaticResource MvvmDefaultRenderableSeriesStyle}">
<Setter Property="RejectionLimit" Value="{Binding RejectionLimit}"/>
...
</Style>
Seems a bit convoluted when all I want to do is programmatically create a custom renderable series, so wanted to check that there isn’t a more straightforward approach.
Hi Andrew,
This is the approach for creating custom series with the MVVM SeriesBinding API. We have a worked example here showing the steps.
Worked Example – CustomRenderableSeries in MVVM
Best regards,
Andrew
Please login first to submit.