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?
- Tore Munch asked 3 years ago
- You must login to post comments
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
- Dmytro Herasymenko answered 2 years ago
- You must login to post comments
Please login first to submit.