I'm trying to set up a SciChart VerticalLineAnnotation similar to the Drag Horizontal Threshold example in the SciChart example suite. I have the annotation bound to a property in my view model, but when dragging the annotation it continually sets the property to a value of 0.
I've tried setting the property value in code and it does move the line as you would expect indicating the binding is fine. I set a breakpoint on the property and confirmed the 0 value is coming from the control, not my code.
<sc:SciChartSurface x:Name="OverviewSurface"
Margin="5,2,5,2"
Background="White"
Grid.Row="2"
Grid.ColumnSpan="4"
Loaded="OnOverviewSurfaceLoaded"
RenderableSeries="{Binding ElementName=ChartSurface, Path=RenderableSeries}"
YAxes="{sc:AxesBinding YAxes}">
<sc:SciChartSurface.XAxis>
<sc:NumericAxis VisibleRange="{Binding VisibleRange}" DrawMajorGridLines="False" DrawMinorGridLines="False" DrawMajorBands="False" Visibility="Collapsed"/>
</sc:SciChartSurface.XAxis>
<sc:SciChartSurface.Annotations>
<sc:VerticalLineAnnotation VerticalAlignment="Stretch"
IsEditable="True"
ShowLabel="False"
Stroke="#FF42b649"
StrokeThickness="4"
YAxisId="ChannelA"
X1="{Binding SelectedIndex, Mode=TwoWay}" />
</sc:SciChartSurface.Annotations>
</sc:SciChartSurface>
I expect that when I drag the Annotation along the horizontal length of the chart that I will get a value corresponding with the X position placed in SelectedIndex, but all I ever get is zero.
The cause of this issue turned out to be the data type of SelectedIndex, which was an unsigned integer. Despite the fact that VerticalLineAnnotation's X/Y value type is IComparable, if you are using the IsEditable="True" function, the drag step size is fractional and if bound to an integer type, it will continually round to 0 making it incapable of movement.
If there is a way to change the step size of the drag in SciChart, I was unable to locate it. Instead I changed SelectedIndex to a double and rounded it to my desired unsigned integer in the setter, which solved my problem.