wpf - ControlTemplate and AddLogicChild/RemoveLogicalChild

Recently I was trying to debug into one mysterious issue where the DockManager from DevExpress is so slow when certain theme is applied.

And I have noticed that there are hotspot such as AddLogicalTree and RemoveLogicalChild on the performance counter. 

Below is a analysis on the result of analysis.


When I drap out a window from the dock manager and put that into a floating group, what I have observed is that first 

1. RemoveLogicalChild is called on its existing logical parent (I blieve that the DockingManager must have certains groups such as FloatingGroup and DockingGroup so that each item/tab falls part of ..)


 

Where then the detached item will be added into a new container, and the AddLogicalChild is called. 



 

and then this Item will be boxed into a new group, which you will see again the AddLogicalChild called again.



 

Also, as I noticed that when a Item detached from the DockingManager and become part of the floating window, you will see the WndProc will be invoked.




 

so the analysis of the result is that extensively uses of the styling through template. Where the logicalTree adding/removing will trigger a huge amount of recalculationg - creating those VisualElement and others will severely bog down the performance.  - As that Styling through the Template can be confirmed though this MSDN page - FrameworkElement.AddLogicalChild. method. 

And this has posed a very interesting question, how do you get the styling done whiles keep the performance. 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值