SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

0
0

I have two similar charts, the first one is rendered in the View and it is working fine, but the other one is rendered in the memory at run time. The both charts share the same RenderableSeries, but when I assign the RenderableSeries to the SciChartSurface Instance at run time then I get the following error message:

Cannot implicitly convert type ‘System.Collections.ObjectModel.ObservableCollection(SciChart.Charting.Model.ChartSeries.ImpulseRenderableSeriesViewModel)’ to ‘System.Collections.ObjectModel.ObservableCollection(SciChart.Charting.Visuals.RenderableSeries.IRenderableSeries)’

I already changed the Data Type of the renderable Series to FastImpulseRenderableSeries but the behavior in the View is not the same.

I am trying to cast each serie but it does not work. do you habe a hint for me?

Version
4.1.1.8625
  • You must to post comments
0
0

Hi there,

You cannot cast IRenderableSeriesViewModel to IRenderableSeries – they are different types (please see our Class Hierarchy, you can see what inherits what).

Instead, you need to convert RenderableSeriesViewModels to RenderableSeries. The way we do this in WPF is via the SeriesBinding MarkupExtension:

<!-- VIEW-->

<!-- Declare a SciChartSurface with SeriesBinding -->
<!-- Where xmlns:s="http://schemas.abtsoftware.co.uk/scichart -->
<s:SciChartSurface RenderableSeries="{s:SeriesBinding RenderableSeriesViewModels}">

   <!-- XAxis, YAxis omitted for brevity -->

</s:SciChartSurface>

// Viewmodel
private ObservableCollection<IRenderableSeriesViewModel> _renderSeriesViewModels;
public ObservableCollection<IRenderableSeriesViewModel> RenderableSeriesViewModels
{
   get { return _renderSeriesViewModels; }
   set
   {
      _renderSeriesViewModels = value;
         OnPropertyChanged("RenderableSeriesViewModels");
   }
}

The equivalent in C# code only is to use a converter, e.g.

List<IRenderableSeriesViewModel> rSeriesViewModels = ... // populate your view models
var sciChartSurface = new SciChartSurface();
sciChartSurface.RenderableSeries = new RenderableSeriesSourceCollection(rSeriesViewModels);

Best regards,
Andrew

  • You must to post comments
0
0

Thanks a lot. It works perfectly now.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.