How to have both right-click event command and context menu.

5 posts, 1 answers
  1. Massimiliano Giustizieri
    Massimiliano Giustizieri avatar
    18 posts
    Member since:
    Oct 2009

    Posted 22 Nov 2012 Link to this post

    Dear Telerik Team,

    I have included a RadContextMenu in my RadScheduleView control, to be able to create new appointments, and other actions ...
    I've noticed that, of course, the context menu appears onto the whole area of the control. Meaning: if I click the resourse header, or the view definition buttons, I can open the context menu in that point.
    I would like to avoid this, and would like my context menu opened only by clicking onto an area that really represents a time span (I think it is called the AppointmentsPanel). So I've tried adding my own Command to the right-click event, where I wanted to check the UIElement at the clicked position and determine wheter to show the context menu or not, but I've found out that this was suppressing the context menu because, I thought, they were using the same event and I created a sort of conflict. I used to CommandManager to add the right-click command.
    My question then is if it's possible to have both a Command bound to the right-click event, and the RadContextMenu on the same control. My approach seemed correct and I simply have to double-check if I made something wrong? Or there is some technical limitation in adding many actions to the same event? In this case would you suggest following any other way to get this working?
    Many thanks!

    Kind Regards,

    Massimiliano Giustizieri, Italy.
  2. Massimiliano Giustizieri
    Massimiliano Giustizieri avatar
    18 posts
    Member since:
    Oct 2009

    Posted 03 Dec 2012 Link to this post

    Any ideas ?

    Thanks!
  3. DevCraft banner
  4. Mohammed
    Mohammed avatar
    5 posts
    Member since:
    Jul 2012

    Posted 09 Dec 2012 Link to this post

    In order to restrict context menu to appear only appointment slot, you can do the following,

    In the RadContextMenu's opening event put the following code snippet,


            private void OnContextMenuOpening(object sender, RadRoutedEventArgs e)
            {
                e.Handled = _radScheduleView.SelectedSlot == null;
            }

    Hope this helps

  5. Massimiliano Giustizieri
    Massimiliano Giustizieri avatar
    18 posts
    Member since:
    Oct 2009

    Posted 11 Dec 2012 Link to this post

    Thank you very much Mohammed,

    I've tried your suggestion, which partially works. The problem that I noticed also before posting, however, is that the right-click not always updates the current selection. This means that you can select a slot, right-click elsewhere (also onto a non-valid area) and see your context menu opening where it shouldn't be.

    Your suggestion is ideally correct if the Schedule would select\deselect the current selection correctly, but I'll need to find a different implementation.

    Thanks anyway!

    Massimiliano Giustizieri, Bari.
  6. Answer
    Yana
    Admin
    Yana avatar
    4554 posts

    Posted 12 Dec 2012 Link to this post

    Hello Massimiliano,

    Please check the reply here.

    All the best,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner