Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 正在尝试将画布添加到Windows窗体应用程序中的WPF ElementHost?_C#_Wpf_Canvas - Fatal编程技术网

C# 正在尝试将画布添加到Windows窗体应用程序中的WPF ElementHost?

C# 正在尝试将画布添加到Windows窗体应用程序中的WPF ElementHost?,c#,wpf,canvas,C#,Wpf,Canvas,我正在尝试在我的应用程序中使用windows平板电脑上的触摸屏。我看到的所有示例都使用system.windows.Input并从WPF画布获取接触点。我的应用程序是winforms应用程序,我没有时间(截止日期本周)转换该应用程序,因此我想尝试elementhost方法,但我不确定如何进行转换 我已经在表单中添加了一个elementhost,然后我想创建一个画布并添加它…但是看起来elementhost只能保存windows窗体控件 System.Windows.Controls.Canvas

我正在尝试在我的应用程序中使用windows平板电脑上的触摸屏。我看到的所有示例都使用system.windows.Input并从WPF画布获取接触点。我的应用程序是winforms应用程序,我没有时间(截止日期本周)转换该应用程序,因此我想尝试elementhost方法,但我不确定如何进行转换

我已经在表单中添加了一个elementhost,然后我想创建一个画布并添加它…但是看起来elementhost只能保存windows窗体控件

System.Windows.Controls.Canvas touchcanvas = new System.Windows.Controls.Canvas();
elementHost1.Controls.Add(touchcanvas);
由于touchcanvas不是有效的windows窗体控件,因此在controls.add上出现错误


如何将WPF画布添加到elementhost并能够引发其事件?例如触摸事件

我认为您需要使用
ElementHost
Child
属性

elementHost1.Child = touchcanvas;

谢谢这很管用……但在这一点上,我如何与孩子互动?我正在尝试实现这一点:在windows窗体应用程序中。我似乎无法让e.GetTouchPoints识别画布。当我还是个孩子的时候,我怎么才能接触到工作?对不起,我不习惯。您是否尝试作为msdn样本?
e.GetTouchPoints
返回什么?它用于所有接触点的迭代循环中。foreach(接触点(e.GetTouchPoints中的接触点)(接触画布));