询问者
WPF 中UI 绘制问题,

问题
-
要想在WPF中的UI控件上面绘制Visual,UI控件中必须要有VisualCollection,还要override 两个方法:
protected override int VisualChildrenCount
{
get { return visuals.Count; }
}/// <inheritdoc />
protected override Visual GetVisualChild(int index)
{
if (index >= visuals.Count)
throw new ArgumentOutOfRangeException("index");return visuals[index];
}可是我的应用程序在运行的时候会无数次的调用者两个方法(貌似是CLR调用的),因此我的应用程序运行的时候比较卡,现在不清楚是否是因为无数次的调用了这两个方法导致的应用程序运行很卡(包括滚动绘制出来的图形时)。哪位大虾能给指点一下啊,谢谢了。
全部回复
-
你有多少个Visual在里面?
“卡”是什么概念?是很高的CPU使用率还是低CPU使用率但程序相应缓慢?
为什么会认为问题出在这个两个方法上呢?如果在这两个方法里面添加log代码(或者简单输出到debug窗口),是否可以观察到频繁的调用?
另外可以用WPF Performance Suite来Profile你的程序,看帧数在多少,有没有硬件加速等信息。
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
If you have any feedback, please tell us.
The All-In-One Code Framework Project
My Blog (in Simplified Chinese)- 已标记为答案 Min-Hong Tang - MSFT 2010年8月18日 2:00
- 取消答案标记 qzterminator 2010年8月19日 10:04