WPF不';使用WindowsFormsHost时,不要总是重新绘制

WPF不';使用WindowsFormsHost时,不要总是重新绘制,wpf,winforms,paint,managed-directx,windowsformshost,Wpf,Winforms,Paint,Managed Directx,Windowsformshost,我有一个简单的应用程序,它使用WindowsFormsHost托管托管DirectX控件。我已覆盖控件中的绘制方法以防止闪烁: protected override void OnPaint(PaintEventArgs e) { if (this.Visible == true) { base.OnPaint(e); } } // Don't paint the background unless the control is not visible protected overri

我有一个简单的应用程序,它使用
WindowsFormsHost
托管托管DirectX
控件。我已覆盖
控件中的绘制方法以防止闪烁:

protected override void OnPaint(PaintEventArgs e)
{
    if (this.Visible == true) { base.OnPaint(e); }
}

// Don't paint the background unless the control is not visible
protected override void OnPaintBackground(PaintEventArgs e)
{
    if (this.Visible == false) { base.OnPaintBackground(e); }
}
有一个计时器会定期使托管DirectX
控件无效,以便重新绘制

我的问题是,当我锁定计算机(WIN+L),然后将其解锁时,
WindowsFormsHost
周围的WPF内容有时无法完全绘制。直到我将窗口完全拖出视图,它的各个部分才被绘制出来。你知道WPF为什么不自己重新粉刷吗


抱歉,如果这太模糊,无法解决问题,我无法共享更多源代码。

更改为SlimDX并放弃WindowsFormsHost。有很多关于将SlimDX与WPF混合的web帖子(包括StackOverflow上的许多项目)。托管的DirectX已经死了。很好的解脱,我说。。。