Pre loader

Create Surface by code

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

Hi,

I am using Scichart 6.1 in WPF application. I want to access ScichartSurface in my view model to call some commands like ZoomExtentsModifier or SuspandUpdate. So I created all controls like surface, Axis, Series and annotations in my code according to your example ‘Creating your First SciChartSurface’.
My question is how can I attach this view model to my view [*.xaml file] ? I couldn’t find any example of xaml file in this case.

Regards

Version
6.1
  • You must to post comments
0
0

Hi Maryam,

Without seeing the code it’s very difficult to offer some advice.

Firstly you don’t need to create a SciChartSurface in code to access ZoomExtents() or SuspendUpdates() in a view model. Instead you can use this technique or alternatively this technique to call SuspendUpdates.

You can also use this technique to call ZoomExtents form a ViewModel.

Let me know if this helps,

Best regards,
Andrew

  • You must to post comments
0
0

Hi Andrew,

I am working on a pretty large application witch I want to replace another chart with Scichart. So, I really need to create Scicharturface in my code because I need to create custom theme, pass surface to my toolbox, call commands like SuspendUpdates or ZoomExtentsCommand. I’ll show you a piece of my work.

Here is my viewmodel:

public class ChartAreaViewModel : BaseModel
    {
        private SciChartSurface _parentSurface;
        public SciChartSurface ParentSurface
        {
            get
            {
                return _parentSurface;
            }
            set
            {
                _parentSurface = value;
                NotifyPropertyChanged(nameof(ParentSurface));
            }
        }
        public ChartAreaViewModel()
        {
            ParentSurface = new SciChartSurface();
            ParentSurface.YAxes = new SciChart.Charting.Model.AxisCollection();
            ParentSurface.RenderableSeries = new ObservableCollection<IRenderableSeries>();
            for (int i = 0; i < 5; i++)
            {
                FastLineRenderableSeries chart = new FastLineRenderableSeries();
                ParentSurface.RenderableSeries.Add(chart);
            }
        }
    }

And this is my view:

<UserControl x:Class="MyApp.Views.UserControls.ChartAreaView"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"             
                 xmlns:sci="http://schemas.abtsoftware.co.uk/scichart">
        <Grid DataContext="{Binding ChartAreaViewModel}">
        </Grid>
    </UserControl>

How can I connect this surface from the view model to the view? Is it necessary to create SichartSurface in view again?

Thanks

  • You must to post comments
0
0

Any thoughts?

  • You must to post comments
Showing 3 results
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