Disable Context Menu on Selected Item

2 posts, 0 answers
  1. Pelli
    Pelli avatar
    11 posts
    Member since:
    May 2014

    Posted 11 Jun 2015 Link to this post

    Hi,

     We have a radtreeview with check boxes. Now we want to support radcontextmenu on checked items and dragdrop on selected items. But when we implement context menu , we are getting even on selected item.

    How can we disable contextmenu on selected item and enable only if it checked. Please provide your inputs.

    Thanks,

    Subhashini

  2. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 12 Jun 2015 Link to this post

    Hello Subhashini,

    You can prevent the context menu from opening by handling the ContextMenuOpening event of the element on which the menu is attached. For example, if the context menu is attached on the RadTreeView control you can subscribe for its event and set the argument's Handled property to True. Here is an example:
    <telerik:RadTreeView ContextMenuOpening="RadTreeView_ContextMenuOpening">
        <telerik:RadTreeView.ContextMenu>
            <ContextMenu>
                <!-- menu items -->
            </ContextMenu>
        </telerik:RadTreeView.ContextMenu>
    </telerik:RadTreeView>

    private void RadTreeView_ContextMenuOpening(object sender, ContextMenuEventArgs e)
    {
        if(the item is selected and is not checked)
        {
            e.Handled = true;           
        }  
    }

    Please try this approach and let me know if it works for you.

    Regards,
    Martin
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top