Pre loader

How to use SeriesBinding from code-behind

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

We’re using ReactiveUI and bindings in code-behind. We’re now upgrading from SciChart v3 to v6 and we’re wondering how to use the SeriesBinding in code-behind like this:

public partial class BarChartView : ReactiveUserControl<sBarChartViewModel>
{
    public BarChartView()
    {
        InitializeComponent();

        this.WhenActivated(disposable =>
        {
            this.OneWayBind(ViewModel,
                            vm => vm.SeriesSource,
                            view => view.BarChart.SeriesSource)
                .DisposeWith(disposable);

            this.OneWayBind(ViewModel,
                            vm => vm.LabelProvider,
                            view => view.FaciesAxis.LabelProvider)
                .DisposeWith(disposable);

            this.OneWayBind(ViewModel,
                            vm => vm.TooltipDataContext,
                            view => view.TooltipModifier.TooltipLabelDataContextSelector)
                .DisposeWith(disposable);

            this.OneWayBind(ViewModel,
                            vm => vm.XAxisRange,
                            view => view.FaciesAxis.VisibleRange)
                .DisposeWith(disposable);
        });
    }
}

Now the IChartSeriesViewModel and SciChartSurface.SeriesSource is deprecated so we have to move to IRenderableSeriesViewModel instead and then bind to SciChartSurface.RenderableSeries. But how can we convert from IRenderableSeriesViewModel to IRenderableSeries here?

Version
6.3.0.13476
  • You must to post comments
0
0

Hi Tore,

The SeriesBinding is a markup extension which uses a special RenderableSeriesSourceCollection.
You can define the ReactiveUI inline binding converter and create the source collection instance manually.

public partial class LineChartExampleView
{
    public LineChartExampleView()
    {
        InitializeComponent();

        ViewModel = new LineChartViewModel();

        this.WhenActivated(disposableRegistration =>
        {
            this.OneWayBind(ViewModel,
                viewModel => viewModel.Series,
                view => view.sciChart.RenderableSeries,
                ViewModelToViewConverterFunc)
            .DisposeWith(disposableRegistration);
        });
    }

    private ObservableCollection<IRenderableSeries> ViewModelToViewConverterFunc(ObservableCollection<IRenderableSeriesViewModel> arg)
    {
        return new RenderableSeriesSourceCollection(arg);
    }
}

Best regards,
Dmytro Herasymenko
SciChart WPF Developer

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies