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

Can right click be made to change selected item?

3 Answers 78 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Roger
Top achievements
Rank 1
Roger asked on 30 Apr 2010, 10:39 PM
Silverlight 4, with the latest build of the Telerik SL controls.

I have a treeview...
I have right click context menus working...

The problem is, if you click on a tree view item... and then 'right click' on a different treeview item, the original treeview item is still selected, not the one you right clicked on.

I tried adding the event for right click to every single Radtreeviewitem, but it looks like the textbox is intercepting the event.

To see what I mean, just open up the samples for the tree view. Click on one item, and right click on another.

Anyone have this working?

Thanks,

3 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 06 May 2010, 07:58 AM
Hello Roger,

please check this example:
http://demos.telerik.com/silverlight/#ContextMenu/FirstLook

Regards,
Valentin.Stoychev
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Patrick
Top achievements
Rank 1
answered on 12 Apr 2011, 02:28 AM
Can you be a bit more specific about how to actually solve this? Please don't make us trawl through your example trying to find what you mean.
0
Kiril Stanoev
Telerik team
answered on 12 Apr 2011, 10:01 AM
Hi Roger,

In the example that Valio shared, you can select the right-clicked TreeViewItem in the  RadContextMenu_Opened method.

private void RadContextMenu_Opened(object sender, RoutedEventArgs e)
{
    RadTreeViewItem item = radContextMenu.GetClickedElement<RadTreeViewItem>();
    item.IsSelected = true;
    if (item != null)
    {
        if (item.Item is SolutionFile)
            radContextMenu.ItemsSource = solutionMenuItems;
        else if (item.Item is ProjectFile)
            radContextMenu.ItemsSource = projectMenuItems;
        else if (item.Item is XAMLFile || (item.Item as CSFile).IsCodeBehindFile)
            radContextMenu.ItemsSource = xamlMenuItems;
        else radContextMenu.ItemsSource = csMenuItems;
    }
}

I'm attaching my test project for further reference. Have a look at it and let me know how it works for you.

Greetings,
Kiril Stanoev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
Roger
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Patrick
Top achievements
Rank 1
Kiril Stanoev
Telerik team
Share this question
or