Annotation Click Event

2 posts, 0 answers
  1. Jason
    Jason avatar
    7 posts
    Member since:
    Nov 2012

    Posted 05 Jun 2015 Link to this post

    I have an annotation on my timeline which I want to move up/down in time.

    I know I can just change the annotations Date to do this, but How can I get the user to interact with the annotation.

    It does not trigger the SelectionChanged event (cos it's not a item).

    Is there a way to identify it the mouse down, move and up events, so I can calculate it's new Date value there??

  2. Martin
    Martin avatar
    1044 posts

    Posted 09 Jun 2015 Link to this post

    Hello Jason,

    In order to achieve your requirement you can subscribe for the MouseLeftButtonDown/Up and MouseMove events of the timeline and inside the MouseMove event handler set the new date of the annotation. You can calculate the date under the mouse using the timeline's ConvertPointToDateTime() method. Here is an example in code for this approach:
    this.xAnnotation.MouseLeftButtonDown += xAnnotation_MouseLeftButtonDown;
    this.xRadTimeline.MouseLeftButtonUp += xRadTimeline_MouseLeftButtonUp;
    this.xRadTimeline.MouseMove += xRadTimeline_MouseMove;
    void xAnnotation_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        this.isDragging = true;
    void xRadTimeline_MouseMove(object sender, MouseEventArgs e)
        if (this.isDragging)
            var point = e.GetPosition(this.xRadTimeline);
            var dateTime = this.xRadTimeline.ConvertPointToDateTime(point);
            this.xAnnotation.StartDate = dateTime;
    void xRadTimeline_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        this.isDragging = false;

        <telerik:TimelineAnnotation x:Name="xAnnotation"                                           
                    <Border Background="#007ACC" Width="10" />
    Note that I am setting the IsHitTestVisible of the annotation to true. This is necessary because its default value is set to False which means that the annotation won't participate in the user interaction and its mouse events won't be fired.

    You can also take a look at the attached project which demonstrates this approach. Please give it a try and let me know if it helps.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
Back to Top