当前位置: 代码迷 >> .NET新技术 >> wpf中类似redrawWindow函数?解决方案
  详细解决方案

wpf中类似redrawWindow函数?解决方案

热度:1452   发布时间:2016-04-25 01:58:14.0
wpf中类似redrawWindow函数?
自定义一个控件,此控件需要每0.01s刷新一次,
我试着用DispatcherTimer类来刷新,在刷新时调用InvalidateVisual函数,让它可以调用OnRender重绘。

用Debug输出调试信息,刷新一次后,InvalidateVisual调用多次,OnRender才一次,
所以认为是InvalidateVisual没有立即重绘,导致没有正确绘制出需要的效果。

请问各位有没有其他的好的办法?

------解决方案--------------------
有关InvlidateVisual,MSDN上有介绍:
This method is not generally called from your application code. The WPF framework-level layout system does its own handling of changes in the visual tree of an element, and would be calling the equivalent of this method when necessary already. Calling this method is necessary only for advanced scenarios. One such advanced scenario is if you are creating a PropertyChangedCallback for a dependency property that is not on a Freezable or FrameworkElement derived class that still influences the layout when it changes.
不知道你的控件是不是符合这样的情况

------解决方案--------------------
vc++实现的
  相关解决方案