Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
295
adding events based on mouse click
posted

I'd like to add a new event to the timeline based on the location of a mouse click.  My question is how to tell where on the timeline the user clicked?

Parents
No Data
Reply
  • 17605
    Verified Answer
    posted

    Hi,

    You can try using the following code:

    private void Timeline1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)

            {

                Point pt = e.GetPosition(this.Timeline1);

     

                double value = this.Timeline1.Axis.GetPixelValue(pt.X);

     

                NumericTimeEntry entry = new NumericTimeEntry() { Time = value, Title = "New Entry" };

     

                NumericTimeSeries series = this.Timeline1.Series[0] as NumericTimeSeries;

                series.Entries.Add(entry);

            }

     

    In the case you are working with DateTime values you can convert the value to DateTime with:

     

    DateTime time = new DateTime((long)value);

     

     

Children