I’m trying to build an entire chart in XAML but I’m unsure how I would bind to DataSeries.
For example…
<sci:SciChartSurface>
<sci:SciChartSurface.XAxis>
<sci:NumericAxis />
</sci:SciChartSurface.XAxis>
<sci:SciChartSurface.YAxis>
<sci:NumericAxis />
</sci:SciChartSurface.YAxis>
<sci:SciChartSurface.RenderableSeries>
<sci:FastImpulseRenderableSeries>
<sci:FastImpulseRenderableSeries.DataSeries>
<!-- Completely made up "DataSeries" XAML tag, but this is the general idea of what I'm wanting to do -->
<DataSeries X="0" Y="{Binding Path=MyObject1.Value}" />
<DataSeries X="1" Y="{Binding Path=MyObject2.Value}" />
<DataSeries X="2" Y="{Binding Path=MyObject3.Value}" />
<DataSeries X="3" Y="{Binding Path=MyObject4.Value}" />
</sci:FastImpulseRenderableSeries.DataSeries>
</sci:FastImpulseRenderableSeries>
</sci:SciChartSurface.RenderableSeries>
</sci:SciChartSurface>
Is it possible to do something along those lines?
If something along those lines were possible I could probably even build out a DataTemplate to just generate the “DataSeries” tags.
Thanks!
- Greg Knox asked 4 years ago
- You must login to post comments
Hi Greg,
One Renderableseries has one DataSeries, so the binding must like this:
<sci:SciChartSurface.RenderableSeries>
<sci:FastImpulseRenderableSeries DataSeries="{Binding Path=ADataSeriesInYourViewModel}}>
</sci:FastImpulseRenderableSeries>
</sci:SciChartSurface.RenderableSeries>
It’s not possible to build the X,Y values in XAML for a dataseries, as DataSeries is not a DependencyObject and must be declared entirely in code behind or in your ViewModel, but you could if you wanted to write an attached property to do a custom action such as build a DataSeries.
More on attached properties can be found at the microsoft documentation here:
https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/attached-properties-overview
Best regards,
Andrew
- Andrew Burnett-Thompson answered 4 years ago
-
Ok! That makes sense. Thanks!
-
Take a look at LineSeriesSource.cs in https://www.scichart.com/example/wpf-chart-example-load-500-series-x-500-points/. It shows an example where we use an attached property as an intermediary to build series. You could do something similar if you want to bind to a custom object and create a DataSeries from it.
- You must login to post comments
Please login first to submit.