I am having a bit of an issue using the click property on an Annotation object. I tried following the example in the TeeChart for .Net Examples application (Welcome !\Tools\Annotation\Annotation Click) but converted it to be used in WPF instead of Windows Forms, but unfortunately that did not work. I also tried looking through this forum and found this question viewtopic.php?f=4&t=13318&p=58028&hilit ... ick#p58028, but it also did not work for me.
I have tried a few different approaches but none seem to be working. Though I am a relatively new TeeChart user, I am able to successfully trigger other events, such as axis click, chart click, series click, etc. just not the annotation click one. I have created a very simple example below to illustrate my point. Any advice would be much appreciated!
Code: Select all
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using Steema.TeeChart.Tools;
using Steema.TeeChart.Styles;
namespace WpfApp1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private Annotation annotation1;
private Line lineSeries1;
public MainWindow()
{
InitializeComponent();
MakeGraph();
}
public void MakeGraph()
{
lineSeries1 = new Line();
lineSeries1.FillSampleValues(20);
tChart1.Series.Add(lineSeries1);
annotation1 = new Annotation
{
AutoSize = true,
Position = AnnotationPositions.LeftBottom,
Text = "Some text"
};
tChart1.Tools.Add(annotation1);
annotation1.Click += Annotation1_Click;
}
/* Does not work */
private void Annotation1_Click(object sender, Steema.TeeChart.Drawing.MouseEventArgs e)
{
MessageBox.Show(annotation1.Text, "Clicked");
}
/* WPF equivalent to function below */
//private void Annotation1_onClick(object sender, System.Windows.Input.MouseEventHandler e)
//{
// MessageBox.Show(annotation1.Text, "Clicked");
//}
/* From TeeChart for .NET Examples demo application: Welcome !\Tools\Annotation\Annotation Click */
//private void Annotation1_onClick(object sender, System.Windows.Forms.MouseEventArgs e)
//{
// MessageBox.Show((sender as TeeChart.Tools.Annotation).Text, "Clicked");
//}
}
}
Erin