Skip to content

Performance Delay When Dynamically Populating WPF ItemsControl with Multiple ContentControls #11082

@PooraniSF4929

Description

@PooraniSF4929

Description

In a WPF application, we are experiencing a significant performance bottleneck when dynamically populating an ItemsControl with a large number of ContentControl elements. The control is configured with a horizontal StackPanel as its ItemsPanelTemplate, and we populate it programmatically using a loop that adds approximately 2000 ContentControl instances. This results in a noticeable delay in UI rendering. The delay scales with the number of items added. We expect the UI to render quickly and the items should be displayed in view once the add button is clicked without delay.

This issue is reproducible in a minimal setup. I have attached a simple sample project for your reference, which demonstrates the rendering delay when dynamically adding a large number of ContentControl elements nearly 2000 to an ItemsControl.

Simple sample - ItemsControl_Sample_WPF.zip

Reproduction Steps

  1. Run the sample
  2. Click the Add Items button to add 2000 content control instances
  3. Observe the delay in UI rendering of the items.

Expected behavior

The UI should render the items quickly, even when adding a large number of lightweight visual elements.

Actual behavior

There is a noticeable delay in rendering 2000 items after the button click. The delay increases with the number of items added.

Delay_In_Displaying_Items_After_Add_Button_Clicked.mp4

Regression?

No response

Known Workarounds

No response

Impact

No response

Configuration

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions