【发布时间】:2012-01-24 09:39:03
【问题描述】:
我有一个几天前制作的自定义 WPF 控件:
public class MapContext : FrameworkElement{
//....
protected override void OnRender(DrawingContext dc) {
// Draw the map
if (mapDrawing != null) dc.DrawDrawing(mapDrawing);
}
mapDrawing 绘图在另一个线程中更新,在该线程中计算所有要显示的几何图形,然后该线程通过调用 InvalidateVisual() 更新 UI:
Application.Current.Dispatcher.Invoke(DispatcherPriority.Render, new Action(delegate { InvalidateVisual(); }));
在InvalidateVisual,MSDN documentation 说:
使元素的渲染无效,并强制进行全新的布局传递。布局循环完成后调用 OnRender。
这不是我想要的行为,因为 MapContext 控件布局没有改变。只有里面的图变了。
问题
是否有适当的方法来强制调用 OnRender 方法而不进行完整的布局传递?
提前致谢
【问题讨论】: