Pre loader

AxisAlignment Binding

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 have some charts binded to a viewmodel. I wanted to produce a bar chart, so I want to modify the AxisAlignment.

If I specify a hardcoded alignment in the XAML, it works fine.

If I bind the alignment to the viewModel, the chart does not render, and I get the following error in the output:

 SciChartSurface didn't render, because an exception was thrown:
      Message: The specified Visual and this Visual do not share a common ancestor, so there is no valid transformation between the two Visuals.

Stack Trace:    at System.Windows.Media.Visual.TransformToVisual(Visual visual)
   at A.cac257c85637821690b32a44bda9b120f.cd0eaed29fc1e87dfe7aa912a7f678b57(FrameworkElement c5aaca7e2018a1512249ec2e2170b4cc6, UIElement c708323fb6eac118d4fd2c5913dc2a6ed)
   at A.cac257c85637821690b32a44bda9b120f.cd0eaed29fc1e87dfe7aa912a7f678b57(FrameworkElement c5aaca7e2018a1512249ec2e2170b4cc6, IHitTestable cc9d5fbe91f2861ee865bbb5439d3b84d)
   at Abt.Controls.SciChart.Visuals.Axes.AxisBase.GetAxisOffset()
   at Abt.Controls.SciChart.Visuals.Axes.AxisBase.GetAxisParams()
   at Abt.Controls.SciChart.Visuals.Axes.AxisBase.OnBeginRenderPass()
   at A.cda144392e546b245ef5bb1ee71f22b3a.c64a51c8ba6b7cbda8b9d9380d6337036(ISciChartSurface c17037e8328cd0abc02d2a6957dfa450c, RenderPassInfo c16b8d70d2b6ecad8f9fca7ac3f5177b8)
   at A.cda144392e546b245ef5bb1ee71f22b3a.c1a2306a5cc0452a04d135e77f0de4ff1(ISciChartSurface c17037e8328cd0abc02d2a6957dfa450c, Size cacf0a4a95d1143f0c11e20d4508e7132)
   at A.cda144392e546b245ef5bb1ee71f22b3a.RenderLoop(IRenderContext2D renderContext)
   at Abt.Controls.SciChart.Visuals.SciChartSurface.ca065c0b671221e0e603d0e9bf2792494()

This is the axis XAML:

 <s:SciChartSurface.XAxis>
                                    <s:NumericAxis AxisAlignment="{Binding XAxisAlignment}" LabelProvider="{Binding LabelProvider}" AutoTicks="False" MajorDelta="1" MinorDelta="1" DrawMinorGridLines="False">
                                    </s:NumericAxis>
                                </s:SciChartSurface.XAxis>

                                <s:SciChartSurface.YAxis>
                                    <s:NumericAxis AxisAlignment="{Binding YAxisAlignment}" AxisTitle="Number of crimes" GrowBy="0,1"/>
                                </s:SciChartSurface.YAxis>

And the properties I’m binding to:

public AxisAlignment XAxisAlignment { get; private set; }

public AxisAlignment YAxisAlignment { get; private set; }

Any help is appreciated.

Thanks,
Charbel

  • You must to post comments
0
0

Hi Chabrel.

Well to prevent this you just need to ensure that on the moment when chart will be loaded each of these properties should have some non default value. Otherwise axis in axis collection won’t be attached to any axis panel and you will get this exception. You can try to initialize them in constructor or if it is dependency property set some default value in property metadata.

Best regards, Yura

  • You must to post comments
Showing 1 result
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