Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3695578
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:38:05+00:00 2026-05-19T04:38:05+00:00

I have found the context menu takes over 10 seconds to display when I

  • 0

I have found the context menu takes over 10 seconds to display when I have 10,000 items in it, I’d like to make this faster (e.g. less than 1 second)

Here is my test code that shows the context menu slowness directly:

private void button1_Click(object sender, RoutedEventArgs e)
        {            
            ContextMenu cm = new ContextMenu();

            for (int i = 0; i < 1000; i++)
            {
                MenuItem mi = new MenuItem();
                mi.Header = "test";                 // this is HOT - 3%
                mi.Tag = this;                      // cold
                for (int j = 0; j < 10; j++)
                {
                    MenuItem mi2 = new MenuItem();  // this is HOT - 1%
                    mi2.Header = "test";            // this is HOT - 12%
                    mi2.Tag = this;                 // cold
                    mi.Items.Add(mi2);              // this is HOT - 6%
                }
                cm.Items.Add(mi);                   // this is HOT - 3%
            }
            cm.IsOpen = true;                       // this is HOT - 72%
        }

According to performance profilers I’ve used, the cm.IsOpen is taking most of the time – but setting the mi.Header is also significant.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:38:06+00:00Added an answer on May 19, 2026 at 4:38 am

    It’s going to be a poor user experience having 1k items at a single level, but how to make context menus with lots\expensive items more responsive, is a fair question.

    The general pattern I use is to initially create my menu with dummy sub-menus. The dummy sub-menus have a single place-holder menu item and I hook the sub-menu opening event. In the event handler I remove the place-holder menu item and add the real items in.

    This pattern allows sub-menus to be created on demand and only if the sub-menu is actually opened. In other words it makes your menu dynamic meaning you do not have to create everything up-front, nor create hundreds of sub-menus which will not be opened.

    This pattern would reduce your initial menu item count from 10k items to 1k for the example above. This should get you down to ~1 second.

    Again 10k menu items with 1k in the root is pretty much unusable in terms of UX. I hope this is just a thought experiment! 🙂

    Example

            ContextMenu cm = new ContextMenu();
    
            for (int i = 0; i < 1000; i++)
            {
                MenuItem mi = new MenuItem();
                mi.Header = "test";
                mi.Tag = this;
    
                object dummySub = new object();
                mi.Items.Add(dummySub);
                cm.Items.Add(mi);
    
                mi.SubmenuOpened += delegate
                {
                    mi.Items.Clear();
    
                    for (int j = 0; j < 10; j++)
                    {
                        MenuItem mi2 = new MenuItem();
                        mi2.Header = "test";
                        mi2.Tag = this;
                        mi.Items.Add(mi2);
                    }
                };
            }
    
            cm.IsOpen = true;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have found examples here: Android - Intent that open widget context menu and
I want to make a WPF Window that behaves like a context menu. So,
I found an example how to use a context menu with actionBar. This example
I have found services like ClearSpring and Widgetbox for putting content snippets onto a
I have found and customized this JQuery script, which displays different content when different
I have found this piece of code in the Haskell sendfile package: http://patch-tag.com/r/mae/sendfile/snapshot/current/content/pretty/src/Network/Socket/SendFile/Linux.hsc --
I have found that I have no problem using require to load something like
I have found many great answers to this from a year ago (when it
I have found this link: http://www.jfree.org/forum/viewtopic.php?f=3&t=6314 Its back in 2007 where they agree that
I have this view which generates interface language options menu def lang_menu(request,language): lang_choices =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.