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,
- Leland asked 5 years ago
- You must login to post comments
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
- Andrew Burnett-Thompson answered 5 years ago
-
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,
-
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 login to post comments
Please login first to submit.