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

0
0

what’s the way to bind the overview control to a chart in code?

I’m looking to add an overview control to a generic xaml chart, but only enable/bind the control when the I set the grid row visible.

I also plan to abstract the overview control into its own, freestanding control in order to bind it to the currently selected chart in a mult-chart window.

thanks in advance.

  • You must to post comments
0
0

Hi there,

If you see our Overview Control Example you will see we use a Xaml binding to set the parent SciChartSurface:

        <sciChart:SciChartOverview Grid.Row="1" ParentSurface="{Binding ElementName=sciChart}" SelectedRange="{Binding ElementName=sciChart, Path=XAxis.VisibleRange, Mode=TwoWay}" sciChart:ThemeManager.Theme="Oscilloscope">            
        </sciChart:SciChartOverview>

The same thing can be achieved in code, simply set

var overview = new SciChartOverview();
overview.ParentSurface = sciChartSurface;
ThemeManager.SetTheme(overview, "Oscilloscope");

You will also need to set the binding from SelectedRange of OverviewControl to XAxis.VisibleRange of the SciChartSurface in code. Please see this MSDN article for guidance on setting bindings in code. The code should look something like this (I’ve not tested it)

  Binding myBinding = new Binding("XAxis.VisibleRange");
  myBinding.Source = sciChartSurface;
  overview.SetBinding(SciChartOverview.SelectedRange, myBinding);

Best regards,
Andrew

  • riverTrader
    Thanks! It is actually easier than your post. Apparently behind the scenes you do the same binding work for the range that you do for parent surface. simply:overviewChart.ParentSurface = sciChartSurface; overviewChart.SelectedRange = XVisibleRange; where overviewChart is the named overview element in the xaml view and XVisibleRange and sciChartsurface are the appropriate properties/objects in the viewModel
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.