Pre loader

VerticalLineAnnotation set ShowLabelProperty to false will not remove the visible lable

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

I did modify this CustomAnnotationChartModifier. I added a databinding to bing the ShowLabelProperty to the IsSelectedProperty.

    // Recreate all annotations, called when LabelsSource property changes or when the
    // CustomAnnotationChartModifier is attached to the parent surface
    private void RebuildAnnotations() {
        if (base.ParentSurface == null || LabelsSource == null)
            return;
        var annotationCollection = base.ParentSurface.Annotations;
        annotationCollection.Clear();
        foreach (var item in LabelsSource) {
            var vla = new VerticalLineAnnotation();
            vla.DataContext = item;
            vla.SetBinding(AnnotationBase.X1Property, new Binding("X1") { Mode = BindingMode.OneWay });
            // bind ShowLabelProperty
            vla.SetBinding(VerticalLineAnnotation.ShowLabelProperty,
                new Binding("IsSelected") { RelativeSource = RelativeSource.Self, Mode=BindingMode.OneWay });
            vla.IsEditable = this.IsEditable;
            // after manipulation: write X1Property back to Viewmodel 
            vla.DragEnded += Annotation_DragEnded;
            vla.LabelPlacement = LabelPlacement.Top;
            // test to set directly ShowLabel = (bool)e.NewValue;
            //vla.Unselected += annotation_SelectionChanged;
            //vla.Selected += annotation_SelectionChanged; 
            if (this.MarkerManipulatedCommand != null)
                vla.ManipulationCompleted += new EventHandler<ManipulationCompletedEventArgs>(manipulationCompleted_EventHandler);
            annotationCollection.Add(vla);
        }
    }

    private void annotation_SelectionChanged(object sender, EventArgs e) {
        var vla = sender as VerticalLineAnnotation;
        if (vla == null) return;
        vla.ShowLabel =vla.IsSelected;
    }

Result: Select the annoation will show the label. Unselect will not remove the label.
I did try the unselected and selected-event to do the same on other way ->same result.
I can see also that each new selection lighter the label (is it shown more than one time?).

How can I add ToolTipLabel inside that CustomAnnotationChartModifier to see the y-values?

Frank

Version
4.2.0.9002
  • You must to post comments
0
0

Hi Frank,

Thanks for your questions. Concerning the ShowLabel property, it should work as expected. Please try changing it in examples with annotations in our Examples Suite, or in a separate project.

So I’m inclined to suggest that the problem lies somewhere in your implementation. Please ensure you don’t have several VerticalLines placed one above another, also that the binding doesn’t get replaced by an explicitly set value.

I can recommend this great tool for inspecting an application at run-time. It shows the complete VisualTree and allows changing object properties with direct feedback on UI.

As to the ToolTipLabels, I’m not quite sure what you mean by that. I think you can have a TextAnnotation with its Text property bound to the Y1 value. Then, bind the ToolTip property to the Text property:

                <s:TextAnnotation IsEditable="True"
                              Text="Buy!"
                              X1="10"
                              Y1="30.5"
                              ToolTip="{Binding Y1, RelativeSource={RelativeSource Self}}" />

Hope this helps! Please let us know about four findings,

Best regards,
Yuriy

  • You must to post comments
0
0

Hi Yuiry,

I did change your Licensing Test App.

MainWindow.caml.cs:

public MainWindow() {
        InitializeComponent();

        var lineDataSeries = new XyDataSeries<double, double>();
        for (int a = 1; a < 500; a++) {
            lineDataSeries.Append(a + 1, Math.Sin(a));
        }
        RenderableSeriesViewModels = new List<IRenderableSeriesViewModel> {
            new LineRenderableSeriesViewModel {DataSeries = lineDataSeries, StyleKey = "LineSeriesStyle"},
        };
        this.DataContext = this;
    }

    public List<IRenderableSeriesViewModel> RenderableSeriesViewModels { get; set; }

MainWindow.xaml:

<s:SciChartSurface
        s:ThemeManager.Theme="Electric"
        RenderableSeries="{s:SeriesBinding RenderableSeriesViewModels}"
        s:RenderSurfaceExtensions.RenderSurfaceType="HighSpeed">
        <s:SciChartSurface.YAxis>
            <s:NumericAxis
                DrawMajorBands="False" />
        </s:SciChartSurface.YAxis>
        <s:SciChartSurface.XAxis>
            <s:NumericAxis
                DrawMajorBands="False" />
        </s:SciChartSurface.XAxis>

        <s:SciChartSurface.Annotations>
            <s:VerticalLineAnnotation
                X1="200"
                IsEditable="True"
                LabelPlacement="Top"
                ShowLabel="{Binding IsSelected, RelativeSource={RelativeSource Self}}" />

            <s:VerticalLineAnnotation
                X1="250"
                IsEditable="True"
                LabelPlacement="Top"
                ShowLabel="{Binding IsSelected, RelativeSource={RelativeSource Self}}" />
            <s:VerticalLineAnnotation
                X1="300"
                IsEditable="True"
                LabelPlacement="Top"
                ShowLabel="{Binding IsSelected, RelativeSource={RelativeSource Self}}" />
        </s:SciChartSurface.Annotations>
    </s:SciChartSurface>

Try it. Don’t forget to use Snoop (known tool – nice 3D visiualisation). I can notice many labels stacked on the top.

Frank

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.