Changing mouse cursor on expanding rows

5 posts, 0 answers
  1. Frank
    Frank avatar
    3 posts
    Member since:
    Jan 2014

    Posted 19 May 2014 Link to this post

    Hi,

    I'm using a TreeListView with many rows and columns. Expanding rows takes some time. That's why I want to change the mouse cursor to a wait cursor during the time the rendering of the rows takes place. 
    I found a solution for this problem for the TreeView in standard WPF:

    private void TreeNodeExpanded(object sender, RoutedEventArgs e)
    {
        TreeViewItem tvi = e.OriginalSource as TreeViewItem;
        if (tvi != null)
        {
            if (tvi.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated)
            {
                EventHandler itemsGenerated = null;
                itemsGenerated = delegate(object s, EventArgs args)
                {
                    if ((s as ItemContainerGenerator).Status == GeneratorStatus.ContainersGenerated)
                    {
                        (s as ItemContainerGenerator).StatusChanged -= itemsGenerated;
                        tvi.Dispatcher.BeginInvoke(DispatcherPriority.DataBind,
     
                            (ThreadStart)delegate
                            {
                                Mouse.OverrideCursor = null;
                            });
                    }
                };
                tvi.ItemContainerGenerator.StatusChanged += itemsGenerated;
                Mouse.OverrideCursor = Cursors.Wait;
            }
        }
    }

    I tried to rewrite the example for the TreeListView. Unfortunately, the ItemContainerGenerator of the TreeListView does not (unlike other older examples I found in this forum) contain a "Status" property or a "StatusChanged" event.

    Is there another way for changing the mouse cursor during rendering time? All I need is an event that is raised when the rendering is finished.

    Thanks a lot and best regards,
    Frank
  2. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 22 May 2014 Link to this post

    Hi Frank,

    Based on your description, I can suggest you to use TreeListView's RowIsExpandedChanging event. It fires before the hierarchy is expanded or collapsed. 

    I hope it will suit your needs.

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Frank
    Frank avatar
    3 posts
    Member since:
    Jan 2014

    Posted 26 May 2014 in reply to Yoan Link to this post

    Hi Yoan,

    Thanks for your reply. I tried the RowIsExpandedChanging and RowIsExpandedChanged events. Unfortunately, both events are raised one directly after the other, but before the rendering of the cells is finished, so the mouse cursor is immediately changed back to normal.
    Do you have any other suggestion?

    Thanks,
    Frank
  5. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 29 May 2014 Link to this post

    Hello Frank,

    You can use TreeListView's LayoutUpdated event as well. Please check the attached sample project for a reference.

    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.
     
  6. Frank
    Frank avatar
    3 posts
    Member since:
    Jan 2014

    Posted 18 Jun 2014 in reply to Yoan Link to this post

    Hi Yoan,

    Thanks for your expample. This helps a lot. The LayoutUpdated event is the event I was looking for.

    Best regards,
    Frank
Back to Top
UI for WPF is Visual Studio 2017 Ready