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

Changing mouse cursor on expanding rows

4 Answers 185 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Frank
Top achievements
Rank 1
Frank asked on 19 May 2014, 12:05 PM
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

4 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 22 May 2014, 09:30 AM
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.
 
0
Frank
Top achievements
Rank 1
answered on 26 May 2014, 03:38 PM
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
0
Yoan
Telerik team
answered on 29 May 2014, 02:14 PM
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.
 
0
Frank
Top achievements
Rank 1
answered on 18 Jun 2014, 03:21 PM
Hi Yoan,

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

Best regards,
Frank
Tags
TreeListView
Asked by
Frank
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Frank
Top achievements
Rank 1
Share this question
or