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

Select row on context menu

6 Answers 265 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Geoff Smith
Top achievements
Rank 1
Geoff Smith asked on 26 Mar 2010, 05:02 PM
Hi,

Is it possible to select the row in a grid when a context menu is opened by right clicking on that row?

6 Answers, 1 is accepted

Sort by
0
Geoff Smith
Top achievements
Rank 1
answered on 26 Mar 2010, 05:33 PM
ah never mind, I just found your example :)
0
Ewerton Miglioranza
Top achievements
Rank 1
answered on 23 May 2010, 06:38 AM
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.
0
rajnikant
Top achievements
Rank 1
answered on 09 Mar 2011, 08:30 AM
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;
                //}
            }
        }
0
Maya
Telerik team
answered on 11 Mar 2011, 02:31 PM
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!
0
David
Top achievements
Rank 1
answered on 14 Jun 2013, 03:55 AM
The example is using code-behind. Is there any ways to implement the same solution just using binding in the xaml?
0
Maya
Telerik team
answered on 14 Jun 2013, 06:40 AM
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.

Tags
GridView
Asked by
Geoff Smith
Top achievements
Rank 1
Answers by
Geoff Smith
Top achievements
Rank 1
Ewerton Miglioranza
Top achievements
Rank 1
rajnikant
Top achievements
Rank 1
Maya
Telerik team
David
Top achievements
Rank 1
Share this question
or