How to place keyboard-triggered RadContextMenu at Appointment

6 posts, 1 answers
  1. Jochen
    Jochen avatar
    7 posts
    Member since:
    Oct 2014

    Posted 07 Aug 2015 Link to this post

    Hello,

     I'm trying to get the RadContextMenu attached to the RadScheduleView to open at the currently selected slot, appointment or empty field using the Apps key (a.k.a. keyboard rightclick).

     

    So far I've tried changing the PlacementTarget ​in the RadContextMenu's OnOpening event, but I can't find a way to get the actual source.

    RadContextMenu.elementCausedContextMenuOpen is TimeLineRulerPanel, hence RadContextMenu.GetClickedElement<AppointmentItem>() returns null.

    Placing the RadContextMenu at MousePoint is not an alternative as it could be anywhere within the application.

     

    So is it event possible to get the current scheduler child control to place the ContextMenu at?

     

    Thanks in advance!

    Jochen

  2. Nasko
    Admin
    Nasko avatar
    588 posts

    Posted 10 Aug 2015 Link to this post

    Hi Jochen,

    Please, check the following article from our help documentation that demonstrates how to achieve the desired functionality using the SelectedSlot and SelectedAppointment properties of RadScheduleView:
    http://docs.telerik.com/devtools/wpf/controls/radscheduleview/howto/get-resource-from-clicked-slot.html

    The approach described in the article demonstrates how depending on the clicked item of RadScheduleView to execute custom logic and get the Resource of the clicked Appointment or Slot.

    Hopes this helps.

    Regards,
    Nasko
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jochen
    Jochen avatar
    7 posts
    Member since:
    Oct 2014

    Posted 10 Aug 2015 Link to this post

    Hi Nasko,

    thanks for your reply, but that's not what I require.

     

    Example:

    Using rightclick on mouse (see first attached file): ContextMenu opens at MousePosition.

    Using Key.App (see ​second attached file): ContextMenu opens at bottom left of ScheduleView.

     

    So what I'd like to do when hitting the Apps key is to ​​position the ContextMenu right at the selected slot and not somewhere unrelated.

     

    Cheers,

    Jochen

  5. Jochen
    Jochen avatar
    7 posts
    Member since:
    Oct 2014

    Posted 10 Aug 2015 in reply to Jochen Link to this post

    Jochen said:

    Example:

    Using rightclick on mouse (see first attached file): ContextMenu opens at MousePosition.

    Using Key.App (see ​second attached file): ContextMenu opens at bottom left of ScheduleView.  

    Oh, attachments got sorted. Well, filenames speak for themselves I guess​

  6. Answer
    Nasko
    Admin
    Nasko avatar
    588 posts

    Posted 12 Aug 2015 Link to this post

    Hi Jochen,

    Thank you for the attached images. It really helped us a lot to better understand your scenario.

    In order to achieve the desired behavior we suggest you to use the Opening event of the ContextMenu and the SelectedAppointment and SelectedSlot properties of RadScheduleView.

    So, when the ContextMenu gets open the event will be fired. Inside it you need to check if there is a SelectedAppointment or SelectedSlot - they are mutually exclusive because of that while the one is set the other is null. If there is a SelectedAppointment you need to get all AppointmentItems using the ChildrenOfType method. Next you need to find which AppointmentItem is equal to the SelectedAppointment and set it as PlacementTarget for the ContextMenu.

    If there is no SelectedAppointment there should be a SelectedSlot as explained above they are mutually exclusive. So, if there is SelectedSlot again using the ChildrenOfType property you need to get the HighlightedItems and set the PlacementTarget with the first found item.

    We have created a sample project that demonstrates the described above approach and you could run and evaluate it.

    Hopes this helps.

    Regards,
    Nasko
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  7. Jochen
    Jochen avatar
    7 posts
    Member since:
    Oct 2014

    Posted 18 Aug 2015 in reply to Nasko Link to this post

    Hi Nasko,

    ​Thank you very much for your detailed answer and the attached sample! That was what I was missing, works perfectly now.

     

    Cheers,

    Jochen

Back to Top
UI for WPF is Visual Studio 2017 Ready