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

How to get context menu instance from the datagrid

4 Answers 48 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Kiran
Top achievements
Rank 2
Kiran asked on 08 Mar 2011, 03:34 PM
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

4 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 10 Mar 2011, 09:52 AM
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!
0
Kiran
Top achievements
Rank 2
answered on 10 Mar 2011, 09:57 AM
Thanks.

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

Thanks
Kiran
0
Hristo
Telerik team
answered on 10 Mar 2011, 12:22 PM
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!
0
Kiran
Top achievements
Rank 2
answered on 11 Mar 2011, 07:00 AM
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.
Tags
Menu
Asked by
Kiran
Top achievements
Rank 2
Answers by
Hristo
Telerik team
Kiran
Top achievements
Rank 2
Share this question
or