ContextMenuOpening not fired if registered in code

6 posts, 0 answers
  1. Markus
    Markus avatar
    13 posts
    Member since:
    Sep 2013

    Posted 13 Dec 2013 Link to this post

    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

  2. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 18 Dec 2013 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Markus
    Markus avatar
    13 posts
    Member since:
    Sep 2013

    Posted 18 Dec 2013 Link to this post

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

  5. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 19 Dec 2013 Link to this post

    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 >>
  6. Markus
    Markus avatar
    13 posts
    Member since:
    Sep 2013

    Posted 19 Dec 2013 Link to this post

    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

  7. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 24 Dec 2013 Link to this post

    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 >>
Back to Top
UI for WPF is Visual Studio 2017 Ready