Ribbon PopupButton leads to slow window resizing and docked-window switching

Ribbon for WPF Forum

Posted 12 years ago by Tony Pulokas
Version: 12.1.0561
Platform: .NET 4.0
Environment: Windows 7 (64-bit)
Avatar

I am using ActiPro Docking and Ribbon.  I have noticed that after clicking on the Ribbon PopupButton, there is a significant delay when the window is resized, or when switching to a different docking window.  Clicking on a Ribbon Button does not lead to such a delay--only the PopupButton.  I believe the delay is tied to the fact that my window contains a DataGrid with thousands of rows that are virtualized.  However, this large DataGrid does not experience any such delay if the PopupButton has not been clicked.

To reproduce the problem, I started with a fresh WPF Application in VS 2010.  Here is the code for MainWindow.xaml

<ribbon:RibbonWindow
    x:Class="RibbonPopupProblem.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared" 
	xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon" 
    xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
    Title="MainWindow"
    Height="350" Width="525" >

    <DockPanel LastChildFill="True" >
        <DockPanel DockPanel.Dock="Top" >
            <ribbon:Ribbon 
                x:Name="ribbon"
                UseScenicLayout="False" >
                <ribbon:Ribbon.Tabs >
                    <ribbon:Tab Label="TestTab" >
                        <ribbon:Group Label="TestGroup" >
                            <ribbon:Button Label="Simple Button 1" Margin="7"/>
                            <ribbon:Button Label="Simple Button 1" Margin="7"/>
                            <ribbon:PopupButton Label="Popup Button 1" Margin="7">
                                <StackPanel>
                                    <Label>Dummy 1</Label>
                                    <Label>Dummy 2</Label>
                                    <Label>Dummy 3</Label>
                                </StackPanel>
                            </ribbon:PopupButton>
                        </ribbon:Group>
                    </ribbon:Tab>
                </ribbon:Ribbon.Tabs>
            </ribbon:Ribbon>
        </DockPanel>

        <DockPanel LastChildFill="True" DockPanel.Dock="Bottom" >
            <docking:DockSite DockPanel.Dock="Right" x:Name="MainDockSite" 
                        ItemContainerRetentionMode="Wrapped"
                        CanToolWindowsAutoHide="False"
                        CanDocumentWindowsRaft="False"
                        CanToolWindowsRaft="False">
                <docking:Workspace x:Name="MainWorkSpace">
                    <docking:TabbedMdiHost>

                        <docking:TabbedMdiContainer>
                            <docking:DocumentWindow Title="Test Window 1">
                                <Grid>
                                    <DataGrid 
                                        x:Name="TestDataGrid1" 
                                        AutoGenerateColumns="True"

                                        EnableRowVirtualization="True"
                                        VirtualizingStackPanel.IsVirtualizing="True"
                                        VirtualizingStackPanel.VirtualizationMode="Recycling" />
                                </Grid>
                            </docking:DocumentWindow>
                            <docking:DocumentWindow Title="Test Window 2">
                                <Grid>
                                    <DataGrid 
                                        x:Name="TestDataGrid2" 
                                        AutoGenerateColumns="True"

                                        EnableRowVirtualization="True"
                                        VirtualizingStackPanel.IsVirtualizing="True"
                                        VirtualizingStackPanel.VirtualizationMode="Recycling" />
                                </Grid>
                            </docking:DocumentWindow>
                        </docking:TabbedMdiContainer>

                    </docking:TabbedMdiHost>
                </docking:Workspace>
            </docking:DockSite>
        </DockPanel>

    </DockPanel>

</ribbon:RibbonWindow>

 And here is the code-behind

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

using ActiproSoftware.Windows.Controls.Ribbon;

namespace RibbonPopupProblem
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : RibbonWindow
    {
        public List<DataItem> _dataItems1 = new List<DataItem>();
        public List<DataItem> _dataItems2 = new List<DataItem>();
        public MainWindow()
        {
            InitializeComponent();

            for (int i = 0; i < 30000; i++)
            {
                _dataItems1.Add(new DataItem { x = i * 2 });
                _dataItems2.Add(new DataItem { x = -i * 6 });
            }

            TestDataGrid1.ItemsSource = _dataItems1;
            TestDataGrid2.ItemsSource = _dataItems2;
        }
    }

    public class DataItem
    {
        public Double x { get; set; }
        public Double y { get { return x / 5; } }
    }
}

Test 1: Start the application.  Do not click on any ribbon buttons.  Maximize the window.  On my computer, this seems to take less than half a second.  Close the application.

Test 2: Start the application. Click on Simple button 1. Maximize the window. On my computer, this seems to take less than half a second. Close the application.

Test 3: Start the application. Click on the PopupButton. Maximize the window. On my computer, this seems to take more than 3 seconds. Close the application.

 

Test 4: Start the application. Do not click on any ribbon buttons. Switch to Test Window 2. On my computer, this seems instant Close the application.

Test 5: Start the application. Click on Simple button 1. Switch to Test Window 2. On my computer, this seems instant. Close the application.

Test 6: Start the application. Click on the PopupButton. Switch to Test Window 2. On my computer, it seems to take more than 1 second. Close the application.

 

Of course, this is a stripped-down project to demonstrate the problem.  The delays are a bit more significant in my real project.

Comments (3)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Tony,

I made a new project with your code and ran through your instructions several times. I couldn't seem to replicate the delays you were talking about with the resizing and switching of the windows. If you want to send over a simple sample project that contains the issue, perhaps in a more significant way, then you may send it to our support address and we'll take another look. If you do, please rename any .zip files so they aren't marked as spam, thank you.

Also, you could try using a performance profiler, like dotTrace, to see if you can narrow down where the slowdowns occur and maybe help you find and fix the problem.


Actipro Software Support

Posted 12 years ago by Tony Pulokas
Avatar

OK, I have tested this on my old Windows XP machine, and on my colleagues' machines.  The slowdown does not occur on my old 32-bit XP machine.  My colleagues and I are all using Win 7 64-bit.  One of them experiences the slowdown, and the other does not.  It appears, however, that the operating system is not the trigger for this, but rather some other software that is running on the computer -- see below.

I have just found this MSDN thread, which reveals the problem to be a notorious bug in .Net 4.0.  When I apply the fix described in this particular reply on the thread, the problem goes away.  I have yet to try to understand all that I can about this fix, but it appears really ugly to me.  It seems pretty clear that this is not really an Actipro problem (I just confirmed that clicking a standard WPF ComboBox also triggers the slowdown), but I would certainly welcome any advice about how I could best work around the bug while using the ribbon controls.

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Tony,

Wow, good find on that thread.  We hadn't heard of that issue before, but it sure seems like a bad one to run into.  Microsoft said they were fixing it in the next service pack.  I'm curious as to whether you find that .NET 4.5 fixes the problem?  Other than that, I'm not sure that we can do anything to help with the issue since it's very core to .NET, and the posted workaround in that thread is probably the only thing you can do.  Our controls just follow the standard UI automation models properly.


Actipro Software Support

The latest build of this product (v24.1.1) was released 22 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.