Select row on context menu

7 posts, 0 answers
  1. Geoff Smith
    Geoff Smith avatar
    48 posts
    Member since:
    Mar 2010

    Posted 26 Mar 2010 Link to this post

    Hi,

    Is it possible to select the row in a grid when a context menu is opened by right clicking on that row?
  2. Geoff Smith
    Geoff Smith avatar
    48 posts
    Member since:
    Mar 2010

    Posted 26 Mar 2010 Link to this post

    ah never mind, I just found your example :)
  3. Ewerton Miglioranza
    Ewerton Miglioranza avatar
    4 posts
    Member since:
    May 2010

    Posted 23 May 2010 Link to this post

    So what?

    Can you please show the example? Keep in mind that when answering yourself a question, others may have the same problem...

    thanks.

    Edit:
    I managed to find it: http://demos.telerik.com/wpf/?GridView/RowContextMenu if anyone else need.
  4. rajnikant
    rajnikant avatar
    1 posts
    Member since:
    Mar 2011

    Posted 09 Mar 2011 Link to this post

    Hi i am using Telerik Gridview.
    On the Context Menu of Telerik Gridview i have a menu of "Tag All" which selects all the rows by default.
    I am implementing using ICommand in MVVM model.
    My view Model has the Command,execute,CanExecute.. methods.
    Please suggest me necessary steps to implement the following in WPF using MVVM .

      <telerik:RadMenuItem
                                    Header="Tag All"
                                    local:CommandBehavior.RoutedEventName="Click"
                                    local:CommandBehavior.TheCommandToRun="{Binding TagShipmentCommand}"
                                    local:CommandBehavior.TheCommandParameter="{Binding ElementName=ReceiversGrid, Path=SelectedItem}">
     </telerik:RadMenuItem>

    private void ExecuteUnTagShipment(object obj)
            {
                var container = (CommandBehaviorEventContainer)obj;
                if (container.Sender != null)
                {
                    var rgv = (RadGridView)container.Sender;
                    //var source = container.e.OriginalSource as FrameworkElement;
                    //if (source != null)
                    //{
                    //    rgv.SelectedItem = source.DataContext;
                    //}
                }
            }
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 11 Mar 2011 Link to this post

    Hello rajnikant,

    May you clarify a bit on your exact requirements? Firstly, you mention that you want to select all the items, but based on the code-snippet provided, I get the impression that you want to set only the SelectedItem.
    In the meantime, just as a possibility, I may suggest you to take a look at the GridViewSelectColumn that will enable you easily to select all the items. 


    Kind regards,
    Maya
    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. David
    David avatar
    1 posts
    Member since:
    Nov 2012

    Posted 13 Jun 2013 Link to this post

    The example is using code-behind. Is there any ways to implement the same solution just using binding in the xaml?
  7. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 14 Jun 2013 Link to this post

    Hello David,

    The same behavior cannot be achieved only through xaml. If you want to keep your code-behind clean, you can create an attached behavior and handle the logic for selection there. 

    Regards,
    Maya
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top