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

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy

We also have a tag=SciChart on where you can earn rep for your questions!


I’m trying to dynamically create chart surfaces and renderable series, but I’m having trouble binding one of the axes to another one, like you would do with this code in XAML:

<s:CategoryDateTimeAxis VisibleRange="{Binding ElementName=priceChart,
                                                                    Mode=TwoWay}" />

I need to accomplish the same thing directly in C# but there are no methods related to binding at all. From the MSDN reference pages I’ve seen that any element that extends FrameworkElement has the Binding property, but it seems the axes don’t extend from that.

Could someone help me out in binding this axis to another axis (for the record, the other one is defined in XAML)?

  • You must to post comments

Hi Sam,

If you cast your SciChartSurface.XAxis to CategoryDateTimeAxis (or AxisBase, or NumericAxis depending on type) it is a FrameworkElement and you should be able to do bindings in code.

E.g. from MSDN

  var myViewModel = new SomeViewModel() {VisibleRange = new IndexRange(0, 100); } 
  Binding visibleRangeBinding = new Binding("VisibleRange");
  visibleRangeBinding.Source = myViewModel;
  ((CategoryDateTimeAxis)sciChartSurface.XAxis).SetBinding(VisibleRangeProperty, visibleRangeBinding);

Best regards,

  • You must to post comments

Awesome, I guess I should have thought of that! Here’s the complete code for future reference:

var macdSurface = new SciChartSurface();

// Create a binding for the X axis
Binding visibleRangeBinding = new Binding("VisibleRange");
visibleRangeBinding.Source = mainWindow.priceChart.XAxis;
visibleRangeBinding.Mode = BindingMode.TwoWay;

// Create and bind
macdSurface.XAxis = new CategoryDateTimeAxis();
((CategoryDateTimeAxis)macdSurface.XAxis).SetBinding(CategoryDateTimeAxis.VisibleRangeProperty, visibleRangeBinding);
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.