1

I have a Controls.ItemsControl (actually a HelixViewport3D) and would like to add it inside a Forms.UserControl.

I already tried this.Controls.Add(new HelixViewport3D()); Where this is a derivative from UserControl however this resulted in an error HelixToolkit.Wpf.HelixViewport3D' to 'System.Windows.Forms.Control. Which makes sense given that they don't inherit anything from one another. Is there a sort of wrapper class in these situations?

using HelixToolkit.Wpf;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


    public partial class HelixForm : Form
    {
        public HelixForm()
        {
            InitializeComponent();
            var _3Dcntr = new HelixViewport3D();
            this.Controls.Add(_3Dcntr);//doesn't work

            //what we worked out so far
            var elemHost = new ElementHost();


        }

    }

I have also noticed that it's supposed to be possible to host a WPF in a winform using ElementHost.Child but adding this variable/function cannot be found in my example code(missing something?), System.Windows.Forms.Integration.ElementHost tells me that System.Windows.Forms.Integration is missing.

Thijser
  • 2,625
  • 1
  • 36
  • 71

1 Answers1

-1

Hosting WPF Composite Control in Winform

Mixing WPF in a Winforms app is not recommended but Microsoft provides a ElementHost in WindowsFormsIntegration namespace.

Here is a more indepth demo of them working Mixing WPF and Winforms

(sorry for the simple answer I have not mixed them before.)

juanvan
  • 671
  • 7
  • 19
  • 'The type of namespace ElementHost cannot be found' no suggestings, same for System.Windows.Forms.Integration – Thijser Jun 08 '16 at 12:19