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

How do I Know the Active Slot When the Context menu is Opening?

3 Answers 85 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
loowool
Top achievements
Rank 2
loowool asked on 29 Sep 2011, 02:09 PM
Dear Telerik,

The ScheduleView implements a Context menu, and I'd like to hide some menu items depending on some info from the active slot and the position of the mouse. So, I added the following to the XAML:
<telerik:RadContextMenu.ContextMenu>
    <telerik:RadContextMenu Opening="contextMenuOpening">
        <telerik:RadMenuItem
            x:Name="menuItemExpenses"
            Header="Expenses"
            Click="menuItemExpenses_Click" />
        <telerik:RadMenuItem
            x:Name="menuItemCreateSlot"
            Header="Create Slot"
            Click="menuItemCreateSlot_Click" />
    </telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>

And in the Opening event handler I'm applying some logic to make visible or not some menu items:
private void contextMenuOpening(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    AppointmentItem appointmentItem = (sender as RadContextMenu).GetClickedElement<AppointmentItem>();
    if (appointmentItem == null)
        menuItemCreateSlot.Visibility = System.Windows.Visibility.Visible;
    else
        menuItemCreateSlot.Visibility = System.Windows.Visibility.Collapsed;
}

The above logic is not enough, as I'd like to know the active slot to be able to decide (not only the Active Appointment as shown above, but also the active slot). Note that the ScheduleView.SelectedSlot and the ScheduleView.MouseOverSlot are most of the time null, and I could not depend on them.

In the attached image you could see that we have different types of slots (each with different attributes and styles), and I need to be able to identify where the user was when the context menu was opening. And if it is a slot, the start and end of the slot, if it's a day header, the date, etc.

Looking forward to your reply, and counting always on your great support.

Salah A. Malaeb
TeknoBuild

3 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 04 Oct 2011, 09:46 AM
Hello Loowool,

RadScheduleView does not provide a public API that you can use to get the active slot per mouse positioning. However, right clicking on a slot selects it, that is why using the SelectedSlot property is the right way to implement the task. Please review our Context Menu online example for more details.

Regards,
Rosi
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Tim
Top achievements
Rank 1
answered on 10 Nov 2011, 11:04 AM
Hi,

I have excactly the same problem. When I open the context menu I need to know what the underlying resource is. Using the SelectedSlot property could work if the slot you clicked on would be selected in all cases. However, there is an issue (maybe a bug): If you rigth-click on a slot to open the context menu for the first time it will select the slot correctly, but if you right click on another slot it will not select the second one.

Everythings works fine as long as you close the context menu using left-click before you open a new one, but we cannot rely on that.
0
Rosi
Telerik team
answered on 11 Nov 2011, 01:40 PM
Hi Stefan,

When RadContextMenu is open a transparent window pops up over the screen. That is why right clicking will not update the slot if you not close the context menu first. This behavior could not be changed at this stage. However we will think about improving it for future versions. We are sorry for the inconvenience this causes to you.

All the best,
Rosi
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
ScheduleView
Asked by
loowool
Top achievements
Rank 2
Answers by
Rosi
Telerik team
Tim
Top achievements
Rank 1
Share this question
or