Nested GridViews double click issue

3 posts, 0 answers
  1. Ryan
    Ryan avatar
    8 posts
    Member since:
    Jun 2012

    Posted 14 Jan 2015 Link to this post

    Hi,
    I am having an interesting issue with nested GridViews using row details.
    I need to be able to double click on rows in both the child and parent GridView and handle them differently.
    But there seems to be an odd behavior where when I double click on the child row the MouseDoubleClickEvent gets raised on the child row first, then a different MouseDoubleClickEvent gets raised on the parent row. Event if I set the first event to being handled a separate event is raised on the parent row.
    The event handlers are being added on the RowLoaded event for both the child and parent GridViews.



    Kind Regards,

    Ryan
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 15 Jan 2015 Link to this post

    Hi Ryan,

    Indeed, this is a routed event and it will be raised for both child and parent rows. You can distinguish which one actually raised the exception through the information coming with e.Source and e.OriginalSource. This is how you can differentiate both the cases.

    Regards,
    Dimitrina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Ryan
    Ryan avatar
    8 posts
    Member since:
    Jun 2012

    Posted 15 Jan 2015 Link to this post

    Hi Dimitrina,
    Thanks for the reply, changing from a RowLoaded event to using the CellDoubleClickEvent and using the original source I was able to tell the difference, like below.

    GridView.AddHandler(GridViewCellBase.CellDoubleClickEvent, new EventHandler<RadRoutedEventArgs>(OnCellDoubleClick), true);



    private void OnCellDoubleClick(object sender, RadRoutedEventArgs e)
    {
        if (e.OriginalSource is GridViewCell)
        {
            var cell = e.OriginalSource as GridViewCell;
     
            object item = cell.ParentRow.Item;
            if (item is TemplateSectionWrapper)
            {
                    var wrapper = item as TemplateSectionWrapper;
                    TemplateSectionEditWindow window = new TemplateSectionEditWindow(context, wrapper.Section);
            }
            else if (item is TemplateSectionInventoryWrapper)
            {
                    var window = new TemplateInventoryEditWindow(context, ViewModel.DeliveryGroups.ToList(), item as TemplateSectionInventoryWrapper);
            }
        }
    }

    Thanks for your help,

    Ryan
Back to Top