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

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

4 Answers 163 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Massimiliano Giustizieri
Top achievements
Rank 1
Massimiliano Giustizieri asked on 22 Nov 2012, 08:44 AM
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.

4 Answers, 1 is accepted

Sort by
0
Massimiliano Giustizieri
Top achievements
Rank 1
answered on 03 Dec 2012, 02:48 PM
Any ideas ?

Thanks!
0
Mohammed
Top achievements
Rank 1
answered on 10 Dec 2012, 05:03 AM
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

0
Massimiliano Giustizieri
Top achievements
Rank 1
answered on 11 Dec 2012, 09:12 AM
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.
0
Accepted
Yana
Telerik team
answered on 12 Dec 2012, 09:22 AM
Hello Massimiliano,

Please check the reply here.

All the best,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ScheduleView
Asked by
Massimiliano Giustizieri
Top achievements
Rank 1
Answers by
Massimiliano Giustizieri
Top achievements
Rank 1
Mohammed
Top achievements
Rank 1
Yana
Telerik team
Share this question
or