Annotation Click Event for WPF

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Erin
Newbie
Newbie
Posts: 6
Joined: Tue Jan 23, 2024 12:00 am

Annotation Click Event for WPF

Post by Erin » Thu Jan 25, 2024 9:52 pm

Hello Steema team :) ,

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");
        //}
    }
}
Kind regards,
Erin

Rubén
Newbie
Newbie
Posts: 20
Joined: Fri Nov 19, 2010 12:00 am

Re: Annotation Click Event for WPF

Post by Rubén » Thu Feb 01, 2024 1:45 pm

Hi Erin,

I apologize for the delay. I have created a demo using the WPF TeeChart package here, https://github.com/Steema/TeeChart-NET- ... ClickEvent. I'm using the namespaces that come from Steema.TeeChart.WPF.

Regards,
Ruben

Erin
Newbie
Newbie
Posts: 6
Joined: Tue Jan 23, 2024 12:00 am

Re: Annotation Click Event for WPF

Post by Erin » Thu Feb 01, 2024 2:40 pm

Hi Ruben,

Thank you for your reply and demo! I wanted to ask you what version of .NET you are using? I am using .NET 7 and the namespaces "using Steema.TeeChart.WPF.Styles" and "using Steema TeeChart.WPF.Tools" don't exist for me. I tried in .NET framework and it worked, but we need it for .NET 7 :)

Kind regards,
Erin

Rubén
Newbie
Newbie
Posts: 20
Joined: Fri Nov 19, 2010 12:00 am

Re: Annotation Click Event for WPF

Post by Rubén » Fri Feb 02, 2024 8:47 am

Hi Erin,
I wanted to ask you what version of .NET you are using?
I'm using NETFramework 4.8.
I tried in .NET framework and it worked, but we need it for .NET 7
True, it's not working correctly in NET7, I will work on fixing the issue and will give you more details. Thank you.

Regards,
Ruben

Erin
Newbie
Newbie
Posts: 6
Joined: Tue Jan 23, 2024 12:00 am

Re: Annotation Click Event for WPF

Post by Erin » Fri Feb 02, 2024 6:04 pm

Thanks so much Ruben for letting me know! Do you by chance know roughly when I can expect to see these namespaces working?

Kind regards,
Erin

Rubén
Newbie
Newbie
Posts: 20
Joined: Fri Nov 19, 2010 12:00 am

Re: Annotation Click Event for WPF

Post by Rubén » Mon Feb 05, 2024 5:35 pm

Hi Erin,

the fix has been completed. We will upload a new version this week. Thank you.

Regards,
Ruben.

Erin
Newbie
Newbie
Posts: 6
Joined: Tue Jan 23, 2024 12:00 am

Re: Annotation Click Event for WPF

Post by Erin » Mon Feb 05, 2024 7:07 pm

Yay! That's awesome news, thanks so much!

Erin :mrgreen:

Erin
Newbie
Newbie
Posts: 6
Joined: Tue Jan 23, 2024 12:00 am

Re: Annotation Click Event for WPF

Post by Erin » Fri Feb 09, 2024 9:26 pm

Hello,

I noticed that you updated TeeChart to include the click fix, thank you so much for that! Unfortunately, I think that the zoom tool is now broken. When a user clicks the chart and moves their mouse, the highlight is always on, tracking the mouse position.

For reference, I added this code to my .NET7 example project I made above:
tChart1.Zoom.Direction = Steema.TeeChart.ZoomDirections.Horizontal;

Kind regards,
Erin

Rubén
Newbie
Newbie
Posts: 20
Joined: Fri Nov 19, 2010 12:00 am

Re: Annotation Click Event for WPF

Post by Rubén » Mon Mar 04, 2024 4:20 pm

Hello,

Sorry for the long delay. I have reviewed the problem and found a side effect change in the source code that caused this issue. I am going to fix it and upload a new version in a few days. I will notify you when the new version is released.

Thank you for your patience,
Ruben.

Rubén
Newbie
Newbie
Posts: 20
Joined: Fri Nov 19, 2010 12:00 am

Re: Annotation Click Event for WPF

Post by Rubén » Wed Mar 06, 2024 1:30 pm

Hello,

A new version has been released with these fixes: https://www.nuget.org/packages/Steema.T ... 4.2024.3.6.

Thanks,
Ruben.

Erin
Newbie
Newbie
Posts: 6
Joined: Tue Jan 23, 2024 12:00 am

Re: Annotation Click Event for WPF

Post by Erin » Wed Mar 06, 2024 6:26 pm

Hi Ruben,

Thank you for the fix and update. I noticed today that the click event for the RectangleTool also does not fire (but dragging works). I'll go ahead and start logging it as a bug in BugZilla, but thought I'd mention it here too.

Best,
Erin

Rubén
Newbie
Newbie
Posts: 20
Joined: Fri Nov 19, 2010 12:00 am

Re: Annotation Click Event for WPF

Post by Rubén » Thu Mar 07, 2024 4:01 pm

Hi Erin,

Thank you for the feedback. I am going to revise the RectangleTool functionality.

Regards,
Ruben

Post Reply