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

Select Row on Right-Click

4 Answers 207 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Matthew Calhoun
Top achievements
Rank 1
Matthew Calhoun asked on 07 Dec 2010, 06:59 PM
Hi,

Is there a way to automatically select the row that is right-clicked on with a RadContextMenu?

<Controls1:RadContextMenu.ContextMenu>
   <Controls1:RadContextMenu x:Name="InternalTowerContextMenu">
      <Controls1:RadMenuItem Header="Add" Command="{Binding NewInternalTowerCommand}" CommandParameter="{Binding ResourceBomGroupTowerAllocation}" />
      <Controls1:RadMenuItem Header="Delete" Command="{Binding DeleteCommand}" CommandParameter="{Binding ResourceBomGroupTowerAllocation}" />
    </Controls1:RadContextMenu>
</Controls1:RadContextMenu.ContextMenu>

For example, right now, I have to left-click on the row, then right-click and select "Delete" for my delete command to work.

Thanks,
Matt

4 Answers, 1 is accepted

Sort by
0
Accepted
Maya
Telerik team
answered on 08 Dec 2010, 08:11 AM
Hello Matthew Calhoun,

You may handle the Opened event of the RadContextMenu like follows:

private void GridContextMenu_Opened(object sender, RoutedEventArgs e)
        {
            RadContextMenu menu = (RadContextMenu)sender;
            GridViewRow row = menu.GetClickedElement<GridViewRow>();
            if(row != null)
            {
                row.IsSelected = true;
            }          
        }

 

Kind regards,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Matthew Calhoun
Top achievements
Rank 1
answered on 08 Dec 2010, 01:58 PM
That worked perfectly, thanks!

Matt
0
Andrey
Top achievements
Rank 1
answered on 13 Mar 2012, 01:28 PM
Does it work in current release?
I receive the following error:

{System.MissingMethodException: Method not found: "System.Collections.Generic.IEnumerable`1<System.Windows.Controls.Primitives.Popup> System.Windows.Media.VisualTreeHelper.GetOpenPopups()".
   at Telerik.Windows.Controls.VisualTreeHelperExtensions.GetElementsInScreenCoordinatesFromOpenedPopups[T](Point globalPosition)
   at Telerik.Windows.Controls.VisualTreeHelperExtensions.GetElementsInScreenCoordinates[T](Point globalPosition, FrameworkElement rootVisual)
   at Telerik.Windows.Controls.VisualTreeHelperExtensions.GetElementsInScreenCoordinatesContextMenu[T](FrameworkElement relativeTo, Point mousePosition)
   at Telerik.Windows.Controls.RadContextMenu.GetClickedElement[T]()
0
Konstantina
Telerik team
answered on 19 Mar 2012, 01:56 PM
Hello Andrey,

Could you please give us some more details about this issue - if you could isolate the problem in a sample application and send it back to us it will be very helpful for tracking down the source of the problem and providing you with a solution in a timely manner.

Looking forward to your reply.

Greetings,
Konstantina
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
GridView
Asked by
Matthew Calhoun
Top achievements
Rank 1
Answers by
Maya
Telerik team
Matthew Calhoun
Top achievements
Rank 1
Andrey
Top achievements
Rank 1
Konstantina
Telerik team
Share this question
or