SuspendLayout to Form and Control

zequion 446 Reputation points
2024-09-17T03:43:58.9466667+00:00

In WPF I have a task that executes a function that loads about 150 titles into a DevExpress NavBar control and a ComboBox. The function takes a long time to finish and it seems that it is because the NavNar control takes a long time to render all the items on the screen. I need a way to do SuspendLayout to the Form and the Control. For the Form I use:

// SuspendLayout.
System.Windows.Threading.Dispatcher MyDispatcher = System.Windows.Threading.Dispatcher.CurrentDispatcher;

System.IDisposable MyThread_IDisposable = MyDispatcher.DisableProcessing();


// ResumeLayout.
MyThread_IDisposable.Dispose();

But it doesn't seem to do anything because the control is rendering the items on the screen. It's because the screen form is not locked. But I don't actually want to lock the form, just the control. I don't know of a way to do SuspendLayout to the control.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,934 questions
{count} votes

1 answer

Sort by: Most helpful
  1. zequion 446 Reputation points
    2024-09-17T23:14:49.2633333+00:00

    I've been told that I can use the control's BeginInit() to add the items and not render them. How do I use this if the control has already been initialized and is displayed?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.