rad grid row doubleclick event to be bound to a command

5 posts, 0 answers
  1. preeti
    preeti avatar
    36 posts
    Member since:
    Oct 2010

    Posted 16 Aug 2012 Link to this post

    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.
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 16 Aug 2012 Link to this post

    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.

  3. preeti
    preeti avatar
    36 posts
    Member since:
    Oct 2010

    Posted 16 Aug 2012 Link to this post

    cant i have a command bound to a click event. is that not possible?
  4. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 17 Aug 2012 Link to this post

    Hello,

     You can use EventToCommand in Blend. 

    All the best,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. Arkadiusz
    Arkadiusz avatar
    2 posts
    Member since:
    Apr 2012

    Posted 23 Aug 2012 Link to this post

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