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

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

0
0

I try to set the position of a vertical line annotation marker in MVVM.

Xaml code looks like this:

<SciChart:SciChartSurface.Annotations>
<SciChart:HorizontalLineAnnotation HorizontalAlignment="Stretch" IsEditable="True" LabelPlacement="Axis" LabelTextFormatting="0.0" ShowLabel="True" Stroke="Orange" StrokeThickness="2" Y1="{Binding Path=UpRightMarkerYPos}" IsHidden="{Binding Path=TimeChartMarkerIsHidden}"/>
<SciChart:VerticalLineAnnotation VerticalAlignment="Stretch" IsEditable="True" LabelPlacement="Axis" LabelTextFormatting="0.0" ShowLabel="True" Stroke="Orange" StrokeThickness="2" X1="{Binding Path=BowMarkerXPos}" IsHidden="{Binding Path=TimeChartMarkerIsHidden}"/>
</SciChart:SciChartSurface.Annotations>

Now I try to set the position of the markers in the viewmodel code.
At startup it takes the correct value.
When changing the marker value in code, it works fine
Now I move the marker with the mouse.
After that, I can not change the position at all in code anymore.

At startup, program hits the get of the BowMarkerXPos property.
After moving the marker with the mouse , the get of the property will not be hit anymore.

    /// &lt;summary&gt;
    /// Gets or sets the BowMarker X position
    /// &lt;/summary&gt;
    public double BowMarkerXPos
    {
        get
        {
            return this.bowMarkerXPos;
        }

        set
        {
            this.bowMarkerXPos = value;
            this.RaisePropertyChanged(&quot;BowMarkerXPos&quot;);
        }
    }

Thanks…

  • You must to post comments
0
0

Hello Egbert,

Thanks for the inquiry, we’ll look into and get back to you when investigated.

Best regards,
Yuriy

  • You must to post comments
0
0

Hi,

We investigated the issue, you can’t deal with annotations in such a way for now. When you move the annotation by dragging it, binding is overridden internally by setting values directly. We try to change this behavior in our next release.

But there is a workaround: you can bind whole AnnotationCollection to ViewModel, create annotations there and also access them directly. So in this case you can set coordinates in VM, and have the same visual output.

Is this workaround suitable for you?

Best regards,
Yuriy

  • You must to post comments
0
0

I have an idea … you can try a TwoWay binding on Y1 property. The reason why this issue occurs is because when you bind to a DependencyProperty you set that DP value to a binding, then later when you drag with the mouse the DP value is overwritten with the value set in code. DependencyProperty precedence is something we’ve learned a lot about during the development of SciChart đŸ˜‰

So, a TwoWay binding helps this because when the DP is set in code within our library, changes are propagated back to the ViewModel.

Can you give this a go and let me know the result? Meanwhile we have a task logged against this and will see what we can do.

Best regards,
Andrew

  • EJansen
    Hi Andrew,This works great.Thanks and best regards, Egbert
  • You must to post comments
0
0

Please confirm – we’ve tested using a TwoWay binding in our lab and it works (ViewModel property is updated even after dragging the line).

Best regards,
Andrew

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.