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

4 posts, 0 answers
  1. loowool
    loowool avatar
    60 posts
    Member since:
    Sep 2006

    Posted 29 Sep 2011 Link to this post

    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
  2. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 04 Oct 2011 Link to this post

    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 >>

  3. DevCraft banner
  4. Ivo
    Ivo avatar
    38 posts
    Member since:
    Jul 2011

    Posted 10 Nov 2011 Link to this post

    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.
  5. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 11 Nov 2011 Link to this post

    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 >>

Back to Top