Pre loader

Bind DataSeries of custom UserControl of FastLineRenderableSeries

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

Sorry for the simple question and please point me to the correct place if I have missed this in the docs.

I am just trying to easily bind the DataSeries of a FastLineRenderableSeries as a custom UserControl.

In my MainView I have placed the custom control:

<customUserControls:CustomLineChart x:Name="CustomLineChart1"
                                                    Grid.Column="1"
                                                    Grid.Row="0" />

My CustomLineChart.xaml is:

 <Grid>
    <sci:SciChartSurface x:Name="simpleLineChart">
        <sci:SciChartSurface.RenderableSeries>
            <sci:FastLineRenderableSeries x:Name="lineRenderSeries"
                                          Stroke="Blue"
                                          StrokeThickness="2" >
            </sci:FastLineRenderableSeries>
        </sci:SciChartSurface.RenderableSeries>

        <!--  Create an X Axis with GrowBy  -->
        <sci:SciChartSurface.XAxis>
            <sci:NumericAxis DrawMajorBands="True"
                             GrowBy="0.1, 0.1" />
        </sci:SciChartSurface.XAxis>

        <!--  Create a Y Axis with GrowBy. Optional bands give a cool look and feel for minimal performance impact  -->
        <sci:SciChartSurface.YAxis>
            <sci:NumericAxis DrawMajorBands="True"
                             GrowBy="0.5, 0.5" />
        </sci:SciChartSurface.YAxis>
    </sci:SciChartSurface>

    <!--ect.....-->

</Grid>

I am trying to figure out how to bind the UserControl lineRenderSeries.DataSeries property in my MainViewModel

So something like this in my MainView.cs:

public partial class MainView : Window
{
    public MainView(MainViewModel vm, IMainFactory mainFactory)
    {
        InitializeComponent();
        DataContext = vm;

        CustomLineChart1.lineRenderSeries.DataSeries = vm.SomeXyDataSeries;
    }
}

Which works if the SomeXyDataSeries is set prior to this object getting created and does not update because it is not bound

Or something like this in my MainView.xaml

<customUserControls:SimpleLineChart x:Name="CoreStrategyPLGraph"
                                                    Grid.Column="1"
                                                    Grid.Row="0" 
                                                    DataSeries="{Binding SomeXyDataSeries}"/>

I have just been having an issue understanding how to properly set up this binding on the UserControl.

Any input/clarification on how to do this would be great!

Thank you,

Version
6.0.2.13028
  • You must to post comments
0
0

It should be as simple as this:

        <sci:FastLineRenderableSeries x:Name="lineRenderSeries"
                                      DataSeries="{Binding DataSeriesPropertyInViewModel}
                                      Stroke="Blue"
                                      StrokeThickness="2" >
        </sci:FastLineRenderableSeries>

The reason is — that the SciChartSurface and FastLineRenderableSeries will inherit the DataContext of CustomLineChart control.

If however you want to specify the DataSeries binding at the toplevel, then you’ll need to declare a dependency property on the CustomLineChart control and pass it down.

Here’s how to do that: Declare a dependency property

  • Leland
    Thank you for your response. Yes I do want to update this at the top level as I am reusing this in multiple areas. I will implement the required dependency properties. Thank you,
  • Chris Kirkman
    I use the dependency property method myself for the same reason. I use my custom chart control in several places in my application.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.