高效的WPF绘图代码 [英] Efficient WPF drawing code
问题描述
我正在通过覆盖Canvas窗口的OnRender函数来编写自定义绘图代码. br/>
受保护的重写void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
//一堆绘图代码
}
我正在绘制的窗口在垂直方向上延伸得很远,因此将其包含在ScrollViewer中.
当系统中的数据更改时,我只想重绘表示该数据的窗口的一小部分,而不是整个窗口.但是,我似乎无法弄清楚如何使窗口的区域无效.我目前正在无效并重新绘制
整个窗口.救命!
谢谢
Aaron
astibich
I am writing custom drawing code by overriding the OnRender function of a Canvas window.
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
// bunch of drawing code
}
The window that I'm drawing stretches very far in the vertical direction, so I contain it in a ScrollViewer.
When data changes in the system, I want to redraw just the small portion of the window that represents that data, not the entire window. However, I can't seem to figure out how to invalidate a region of the window. I am currently invalidating and redrawing
the entire window. Help!
Thanks,
Aaron
astibich
推荐答案
为什么不创建一个包含StackPanel这样的布局面板并包含该部分并调用无效吗?
Why don't you create a layout panel like StackPanel containing that portion and call invalidate on it?
谢谢,
穆罕默德
shujaatsiddiqi.blogspot.com
Thanks,
Muhammad
shujaatsiddiqi.blogspot.com
这篇关于高效的WPF绘图代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!