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

rad grid row doubleclick event to be bound to a command

4 Answers 116 Views
GridView
This is a migrated thread and some comments may be shown as answers.
preeti
Top achievements
Rank 1
preeti asked on 16 Aug 2012, 11:50 AM
hi,

i want to bind the grids row double click event to a command in my view model where i need to paas the entire row object as parameter. can you send me a demo code for this. or help me with some code sample.

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 16 Aug 2012, 12:07 PM
Hello,

The closest option we can offer you is illustrated on this demo:
http://demos.telerik.com/silverlight/#GridView/ClickEvents 

Greetings,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
preeti
Top achievements
Rank 1
answered on 17 Aug 2012, 04:22 AM
cant i have a command bound to a click event. is that not possible?
0
Vlad
Telerik team
answered on 17 Aug 2012, 05:57 AM
Hello,

 You can use EventToCommand in Blend. 

All the best,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Arkadiusz
Top achievements
Rank 1
answered on 23 Aug 2012, 11:04 AM
This is solution we are using, please note that u have to start using your namespace and assembly in xaml instead of defaults:
It could be easily rewrote into attachable property which is probably better solution.

public class YoursRadGridView : Telerik.Windows.Controls.RadGridView
   {
       public YoursRadGridView ()
       {
           doubleClickHandler = new MouseButtonEventHandler((sender, args) =>
           {
               if (args.ClickCount % 2 == 0)
                   if (DoubleClickRowCommand != null)
                       DoubleClickRowCommand.Execute(SelectedItem);                  
           });
 
           RowLoaded += (s, e) =>
           {
               e.Row.AddHandler(GridViewRow.MouseLeftButtonDownEvent, doubleClickHandler, true);
           };
           RowUnloaded += (s, e) =>
           {
               e.Row.RemoveHandler(GridViewRow.MouseLeftButtonDownEvent, doubleClickHandler);
           };
       }
 
       public ICommand DoubleClickRowCommand
       {
           get { return (ICommand)GetValue(DoubleClickRowCommandProperty); }
           set { SetValue(DoubleClickRowCommandProperty, value); }
       }
 
       // Using a DependencyProperty as the backing store for SelectedItemsEx.  This enables animation, styling, binding, etc...
       public static readonly DependencyProperty DoubleClickRowCommandProperty =
           DependencyProperty.Register("DoubleClickRowCommand", typeof(ICommand), typeof(MsRadGridView), new PropertyMetadata(null));
 
       MouseButtonEventHandler doubleClickHandler;
   }
Tags
GridView
Asked by
preeti
Top achievements
Rank 1
Answers by
Vlad
Telerik team
preeti
Top achievements
Rank 1
Arkadiusz
Top achievements
Rank 1
Share this question
or