How to get context menu instance from the datagrid

5 posts, 0 answers
  1. Kiran
    Kiran avatar
    56 posts
    Member since:
    Dec 2008

    Posted 08 Mar 2011 Link to this post

    I am having a context menu inside a grid. i need to access this context menu instance from gridview children.
    How can i achieve this?

    <telerikGridView:RadGridView x:Name="Projects"
                                    
                    <telerikNavigation:RadContextMenu.ContextMenu>
                        <telerikNavigation:RadContextMenu                           
                            >
                            <telerikNavigation:RadMenuItem Header="Add"/>                        <telerikNavigation:RadMenuItem IsSeparator="True"/>                        
                            <telerikNavigation:RadMenuItem Header="Delete"/>  
                        </telerikNavigation:RadContextMenu>
                    </telerikNavigation:RadContextMenu.ContextMenu>
      
                      
      </telerikGridView:RadGridView>

    Thanks
    Kiran
  2. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 10 Mar 2011 Link to this post

    Hello Kiran,

    RadContextMenu is attached on the RadGridView so you could use the static methods on RadContextMenu:
    GetContextMenu(radGridView) and SetContextMenu(gridView, contextMenu) from codebehind.

    Let us know if you need more information.

    Greetings,
    Hristo
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. DevCraft banner
  4. Kiran
    Kiran avatar
    56 posts
    Member since:
    Dec 2008

    Posted 10 Mar 2011 Link to this post

    Thanks.

    Also can i get the gridview instance from context menu also?

    Thanks
    Kiran
  5. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 10 Mar 2011 Link to this post

    Hi Kiran,

    RadContextMenu expose the UIElement on which it is attached through UIElement property.

    Best wishes,
    Hristo
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  6. Kiran
    Kiran avatar
    56 posts
    Member since:
    Dec 2008

    Posted 11 Mar 2011 Link to this post

    Thanks for that info . It helped me. I need one more help

    MyGrid.FilterDescriptors.ItemChanged += new System.EventHandler<
    Telerik.Windows.Data.ItemChangedEventArgs<Telerik.Windows.Data.IFilterDescriptor>>(FilterDescriptors_ItemChanged);

    void FilterDescriptors_ItemChanged(object sender, Telerik.Windows.Data.ItemChangedEventArgs<Telerik.Windows.Data.IFilterDescriptor> e)

    {

    }



    How can i access the context menu form the sender in FilterDescriptors_ItemChanged .
    Why i am asking is i am doing MVVM so i will be writing attached property to hook this event and inside that i need to access the contextmenu and from that context menu the grid attached to it.
Back to Top
DevCraft banner