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?
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);