MahApps / MahApps.Metro

A framework that allows developers to cobble together a better UI for their own WPF applications with minimal effort.
https://mahapps.com
MIT License
9.28k stars 2.45k forks source link

Massive performance impact when adding/removing controlls #3390

Closed TraxXavier closed 5 years ago

TraxXavier commented 5 years ago

I noticed that when I add

<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />

to my App.xaml my code that adds and removes children (custom user controls) to a grid control needs 10x as long as it normally needs.

it is in the order of 5000 ms to remove 130 controls form the grid.

The user Control contains just a label, two combo boxes and 3 buttons.

Leaving only 1 combobox still needs about 1300ms

Is that large performance impact of this styling library a known issue?

EDIT: when I add:

                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
                <!-- Accent and AppTheme setting -->
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />

to its even slower!

Also i noticed that styling only some of the windows involved can yields an even worst result than styling the entire application.

Other people also seam to have noticed: https://stackoverflow.com/questions/23886077/mahapps-slows-down-wpf-application

punker76 commented 5 years ago

@TraxXavier Have you tried to using the virtualized ComboBox style? Because it's not the default.

https://github.com/MahApps/MahApps.Metro/blob/c70a970b52780e57cdf22af9eb9a395cca878e18/src/MahApps.Metro/Styles/Controls.ComboBox.xaml#L611

I know that there are some tweeks to increase the performance when using the styles, I'm working on it...

punker76 commented 5 years ago

@TraxXavier Is it possible for you to create a sample with your behavior which shows this issue?