Can right click be made to change selected item?

4 posts, 0 answers
  1. Roger
    Roger avatar
    25 posts
    Member since:
    Sep 2007

    Posted 30 Apr 2010 Link to this post

    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,
  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 06 May 2010 Link to this post

    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.
  3. DevCraft banner
  4. Patrick
    Patrick avatar
    5 posts
    Member since:
    Aug 2010

    Posted 11 Apr 2011 Link to this post

    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.
  5. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 12 Apr 2011 Link to this post

    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
Back to Top