无法在WPF中将System.windows.Controls.Image隐式转换为System.windows.form.control

时间:2013-10-31 15:05:36

标签: c# wpf

我是WPF的新手。我正在将应用程序从Windows窗体应用程序转换为WPF应用程序。 Windows窗体应用程序正常工作。我必须创建一个渲染图像的设备。因为我使用以下代码。 //定义渲染控件

private System.Windows.Forms.Control renderControl;

//get and set rendercontrol

public System.Windows.Forms.Control RenderControl

  {

       get { return renderControl; }
    set { renderControl = value;  }
    }

//PresentParameters

pp = new PresentParameters();

pp.Windowed = true;

pp.SwapEffect = SwapEffect.Discard;

    device = new Microsoft.DirectX.Direct3D.Device(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, renderControl, CreateFlags.SoftwareVertexProcessing, pp);

我导入了这个类,并使用WPF Image作为renderControl。但它产生的错误无法隐含从Windows.Forms.Control的windows.Controls.Image隐藏。我怎么能转换?有没有其他方式来渲染或创建设备?

1 个答案:

答案 0 :(得分:0)

WPF控件与Windows窗体控件不兼容或不可互换。在WPF中托管Direct3D表面的最佳方法是使用D3DImage