This is a migrated thread and some comments may be shown as answers.

ContextMenuOpening not fired if registered in code

5 Answers 114 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Markus
Top achievements
Rank 1
Markus asked on 13 Dec 2013, 05:01 PM

I have a RadCartesianChart and want to register for ContextMenuOpening. When I do it in XAML my event handler gets called. If I do in code (e.g. MainWindow_Loaded: Chart.ContextMenuOpening += Chart_ContextMenuOpening) it is not called.


I got a small repro too.



Markus

5 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 18 Dec 2013, 02:38 PM
Hi Markus,

Did you forget to attach the project you mentioned? I can't see it attached to your post. Can you please upload it again?

I couldn't reproduce the problem you mentioned in a simple app. Perhaps the problem is more complicated, so a demo project that demonstrates it will be very helpful.

Regards,
Yavor
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Markus
Top achievements
Rank 1
answered on 18 Dec 2013, 02:42 PM

There you go: http://sdrv.ms/1h2o9gU

0
Yavor
Telerik team
answered on 19 Dec 2013, 12:52 PM
Hello Markus,

I checked your project and everything seems to be ok. I didn't find a context menu opening event handler added to xaml or in code behind. I added one in code behind and it is called as expected. To test it actually I added a dump in the output. So download the attached project, build it, run it and observe the Output window of your Visual Studio. It should print "Chart_ContextMenuOpening".

Regards,
Yavor
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Markus
Top achievements
Rank 1
answered on 19 Dec 2013, 12:56 PM

Hi,


In MainWindow.xaml.cs Line 62



// UNCOMMENT THIS

// Chart.ContextMenuOpening += Chart_ContextMenuOpening;




At the same time remove



ContextMenuOpening
="Chart_ContextMenuOpening"


from MainWindow.xaml in Line 13



Markus

0
Petar Marchev
Telerik team
answered on 24 Dec 2013, 11:40 AM
Hello Markus,

I downloaded the project that Yavor uploaded and I can see that the 62nd line in MainWindow is not commented and there is no ContextMenuOpening="Chart_ContextMenuOpening" anywhere in the code.
Just as Yavor explained upon clicking the right button of the mouse the ContextMenuOpening event is raised and a line is added in the output window. Do test the provided project and see that everything works as expected.

Regards,
Petar Marchev
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Chart
Asked by
Markus
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Markus
Top achievements
Rank 1
Petar Marchev
Telerik team
Share this question
or