Item Clicking

2 posts, 0 answers
  1. Aziz
    Aziz avatar
    32 posts
    Member since:
    Sep 2011

    Posted 06 Jan 2012 Link to this post

    When i open the context menu i need to know where i clicked. i Know how to tell what item i clicked on but what if i clicked on white space where there is no item...

    think of a file tree... when i right on click on a folder i want to make a new item in that folder but when i click outside of that folder i want to make one in the root... also you would have to then trap the items saying that files cant have child elements while folders can.

    is there a way to tell a treeview that has drag and drop enabled that some items can have child elements but some cant?

    also how do you tell if i right clicked the context menu just over the treeview not the treeviewitem?
  2. Maya
    Maya avatar
    4062 posts

    Posted 09 Jan 2012 Link to this post

    Hello Jacob,

    You can handle Opening event of RadContextMenu and get the underlying clicked element:

    private void RadContextMenu_Opening(object sender, Telerik.Windows.RadRoutedEventArgs e)
                var contextMenu = sender as RadContextMenu;
                var clickedElement = contextMenu.GetClickedElement<FrameworkElement>();

    Once you get clickedElement, you can gets its parent using ParentOfType<T> extension method. Then depending on the parent, you can perform the logic you require.  

    All the best,
    the Telerik team

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

Back to Top