Expand hierarchy on mouse enter

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

    Posted 15 Aug 2014 Link to this post

    I'm looking for a way to define a mouse enter event for the expand button on a hierarchy gridview. I have nested grids and a drag and drop functionality. I want to be able to start dragging and then mouse over the + and expand another row to drop into the child gridview. Is this a possibility?
  2. Mark
    Mark avatar
    3 posts
    Member since:
    Jun 2012

    Posted 18 Aug 2014 Link to this post

    I think I'm basically trying to do the treeview DropExpandDelay in a gridview.
  3. Yoan
    Admin
    Yoan avatar
    1213 posts

    Posted 19 Aug 2014 Link to this post

    Hi Mark,

    If you want to expand the row when the mouse is over the + button, then you can use GridView's PreviewMouseMove event. Then you can find the underling element, verify it is GridViewToggleButton and expand the row details. Please check the following code snippet for a reference:
    private void clubsGrid_PreviewMouseMove(object sender, MouseEventArgs e)
          {
              var element = e.OriginalSource as FrameworkElement;
     
              var toggleButton = element.ParentOfType<GridViewToggleButton>();
     
              if (toggleButton != null)
              {
                  var row = toggleButton.ParentOfType<GridViewRow>();
     
                  if (row != null)
                  {
                      row.DetailsVisibility = Visibility.Visible;
                  }
              }
          }

    I hope tihs helps.

    Regards,
    Yoan
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top