2013-10-31 42 views
1

我完全是WPF的新手。我將應用程序從Windows窗體應用程序轉換爲WPF應用程序。 Windows窗體應用程序正常工作。我必須創建一個渲染圖像的設備。爲此,我使用下面的代碼。 //定義渲染控制無法隱式轉換System.windows.Controls.Image到WPF中的System.windows.form.control中

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圖像作爲renderControl。但它產生的錯誤不能隱含地從windows.Controls.Image轉換爲Windows.Forms.Control。我如何轉換?有沒有其他的方式來渲染或創建設備?

回答

0

WPF控件與Windows窗體控件不兼容或不可互換。在WPF中託管Direct3D表面的最好方法是使用D3DImage

+0

謝謝。我會嘗試更新 – Ismail

相關問題