Use window.form control in wpf
in window tag
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
add a window.form.picturebox
<windowsformshost>
<wf:picturebox x:name="LiveImage" xmlns:x="#unknown" xmlns:wf="#unknown" />
</windowsformshost>
and now call attach method
public void Attach(System.Windows.Controls.Image control)
{
deviceHandle = Class1.Avicap32.capCreateCaptureWindow("", Class1.Constants.WS_VISIBLE | Class1.Constants.WS_CHILD, 0, 0, control.Width, control.Height, control.Handle, 0);
if (Class1.User32.SendMessage(deviceHandle, Class1.Constants.WM_CAP_DRIVER_CONNECT, (IntPtr)0, (IntPtr)0).ToInt32() > 0)
{
Class1.User32.SendMessage(deviceHandle, Class1.Constants.WM_CAP_SET_SCALE, (IntPtr)(-1), (IntPtr)0);
Class1.User32.SendMessage(deviceHandle, Class1.Constants.WM_CAP_SET_PREVIEWRATE, (IntPtr)0x42, (IntPtr)0);
Class1.User32.SendMessage(deviceHandle, Class1.Constants.WM_CAP_SET_PREVIEW, (IntPtr)(-1), (IntPtr)0);
Class1.User32.SetWindowPos(deviceHandle, new IntPtr(0), 0, 0, 206,187, 2);
}
else
{
MessageBox.Show("Webcam not found ");
Class1.User32.DestroyWindow(deviceHandle);
}
}