Pre loader

VerticalLineAnnotation binding issue

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

For some reason SciChart cannot render two VerticalLineAnnotation bound to to the viewmodel.

I have the following xaml

    <sciChart:SciChartSurface.Annotations>
                            <sciChart:VerticalLineAnnotation VerticalAlignment="Stretch" FontSize="12" FontWeight="Bold" ShowLabel="True" Stroke="Orange" StrokeThickness="2" X1="{Binding Data.Region.Right}"/>
                            <sciChart:VerticalLineAnnotation VerticalAlignment="Stretch"  FontSize="12" FontWeight="Bold" ShowLabel="True" Stroke="Orange" StrokeThickness="2" X1="{Binding Data.Region.Left}"/>
                        </sciChart:SciChartSurface.Annotations>

When I place hardcoded values it works. And the first of the vertical line annotation always gets rendered correctly. Seems like a bug to me.

Images
  • You must to post comments
0
0

Hi there,

Ok I’ve tried to reproduce this on our side and I’m afraid I can’t (please see attached). In this example the two VerticalLineAnnotations are bound to properties in a view model. You can try commenting out the OnPropertyChanged and it still works.

Can you help us reproduce? It may be something subtle with the semantics of the A.B.C.D binding.

Best regards,
Andrew

MainWindow.xaml

<Window x:Class="WpfApplication1.MainWindow"
        xmlns=" http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x=" http://schemas.microsoft.com/winfx/2006/xaml"  xmlns:wpfApplication1="clr-namespace:WpfApplication1"
        xmlns:s=" http://schemas.abtsoftware.co.uk/scichart" 
        Title="MainWindow" Height="350" Width="525">
    
    <Window.Resources>
        <wpfApplication1:MainViewModel x:Key="vm" Left="1.23" Right="4.56"/>
    </Window.Resources>
    <Grid DataContext="{StaticResource vm}">
        <s:SciChartSurface>
            <s:SciChartSurface.YAxis>
                <s:NumericAxis/>
            </s:SciChartSurface.YAxis>
            <s:SciChartSurface.XAxis>
                <s:NumericAxis/>
            </s:SciChartSurface.XAxis>

            <s:SciChartSurface.Annotations>
                <s:VerticalLineAnnotation VerticalAlignment="Stretch" FontSize="12" FontWeight="Bold" ShowLabel="True" Stroke="Orange" StrokeThickness="2" X1="{Binding Right}"/>
                <s:VerticalLineAnnotation VerticalAlignment="Stretch" FontSize="12" FontWeight="Bold" ShowLabel="True" Stroke="Orange" StrokeThickness="2" X1="{Binding Left}"/>
            </s:SciChartSurface.Annotations>
            
        </s:SciChartSurface>
    </Grid>
</Window>

MainViewModel.cs

using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace WpfApplication1
{
    public class MainViewModel : INotifyPropertyChanged
    {        
        private double left;

        public double Left
        {
            get { return left; }
            set
            {
                if (left == value) return;
                left = value;
                OnPropertyChanged("Left");
            }
        }


        private double right;

        public double Right
        {
            get { return right; }
            set
            {
                if (right == value) return;
                right = value;
                OnPropertyChanged("Right");
            }
        }
        


        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
Images
  • nitroxn
    The only thing we are doing different is displaying the graph using a data template and displaying it in a contentpresenter. I will re-examine this code one more. Thanks for the quick help again.
  • Selvaganapathi Kasi
    I tried with same code above. It worked fine. However, I am not sure what should be the X1 value if my x-axis is DateTimeAxis. Please help
  • Andrew Burnett-Thompson
    If the XAxis is a DateTimeAxis, then X1 should be a DateTime. If the XAxis is a NumericAxis, then X1 should be a Double. If the XAxis is a CategoryDateTimeAxis then X1 should be an integer (index to data) Hope this helps!
  • 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