Reputation: 161
I'm trying to get the ability to use the touch screen on a windows tablet in my application. All the examples I've seen use system.windows.Input and get touch points from a WPF canvas. My app is a winforms app and I don't have the time (deadline this week) to convert the app, so I thought to try the elementhost method, but I'm not sure how to go about this.
I've added an elementhost to my form, and then I wanted to create a canvas and add it...but it looks like the elementhost will only hold windows forms controls?!?
System.Windows.Controls.Canvas touchcanvas = new System.Windows.Controls.Canvas();
elementHost1.Controls.Add(touchcanvas);
It gives me an error on the controls.add because touchcanvas is not a valid windows forms control.
How can I add a WPF canvas to the elementhost and be able to raise it's events? such as touch events
Upvotes: 1
Views: 1169
Reputation: 73502
I believe you need to use Child
property of ElementHost
.
elementHost1.Child = touchcanvas;
Upvotes: 2