Select Row on Right-Click

5 posts, 1 answers
  1. Matthew Calhoun
    Matthew Calhoun avatar
    6 posts
    Member since:
    Nov 2009

    Posted 07 Dec 2010 Link to this post

    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
  2. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 08 Dec 2010 Link to this post

    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
  3. Matthew Calhoun
    Matthew Calhoun avatar
    6 posts
    Member since:
    Nov 2009

    Posted 08 Dec 2010 Link to this post

    That worked perfectly, thanks!

    Matt
  4. Andrey
    Andrey avatar
    5 posts
    Member since:
    Sep 2012

    Posted 13 Mar 2012 Link to this post

    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]()
  5. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 19 Mar 2012 Link to this post

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