Getting selected item via "right click"

2 posts, 0 answers
  1. Pavel
    Pavel avatar
    26 posts
    Member since:
    May 2013

    Posted 25 Oct 2017 Link to this post

    Is there a way to get the selected item when performing a 'right click" in the Timeline? I have set up a context menu for the elements in my timeline, but

    I have no way of getting to the object that was right-clicked. If you left click first and then right-click, I am able to get the selected item, but there appears

    to be no method via "right click".

    Paul

  2. Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    268 posts

    Posted 26 Oct 2017 Link to this post

    Hi Pavel,

    You can handle the RadContextMenu's Opened event and then get the clicked element with its GetClickedElement method. Then you can set the RadTimeline's SelectedItem to this element's underlying DataItem. Here is an example of how you can do that:

    private void RadContextMenu_Opened(object sender, RoutedEventArgs e)
    {
                var timelineItemControl = this.radContextMenu.GetClickedElement<TimelineItemControl>();
                var timelineDataItem = timelineItemControl.DataContext as TimelineDataItem;
                this.radTimeline.SelectedItem = timelineDataItem.DataItem;
    }

    You can also read some more about the Selection in RadTimeline in our documentation.

    I hope this is helpful. Let me know if I can be of any further assistance.

    Regards,
    Vladimir Stoyanov
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top