I am currently creating a virtualized TreeView control for an application I'm working on. My current implementation is based on an optimized measurement algorithm that gives me some problems. Now, before I find out the details, please note that I am using .NET version 4.0.
What I did to optimize the measurement of the internal TreeView element minimizes the work done in the MeasureOverride () function. I got to the simplest things and now I remain a costly challenge in the back of WPF. Basically, calling Measure () on a control applies all the templates on auxiliary controls, which is very expensive. Since my TreeViewItems will have a certain height, I do not need a template at the measurement stage. Does anyone know a workaround for calling ApplyTemplates () ?
Here's an example call stack
- MyCustomControl.MeasureOverride (...)
- ...
- UIElement.Measure (...)
- FrameworkElement.MeasureCore (...)
- FrameworkElement.ApplyTemplate (...) <- Expensive!
source share