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

Item Clicking

1 Answer 54 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Aziz
Top achievements
Rank 1
Aziz asked on 06 Jan 2012, 04:26 PM
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?

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 09 Jan 2012, 07:51 AM
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,
Maya
the Telerik team

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

Tags
TreeListView
Asked by
Aziz
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or