-
-
Notifications
You must be signed in to change notification settings - Fork 334
Embedding Eto.Forms in an existing application
cwensley edited this page Oct 7, 2014
·
8 revisions
Note the following requires v2 of Eto.Forms or later (currently, the develop branch)
To use Eto.Forms within an existing application, you need to initialize Eto.Forms after the startup of your app using the following to 'attach' to the existing application (make sure to change the platform to the one you want):
new Eto.Forms.Application(Eto.Platforms.WinForms).Attach();
Then, you should be able to use any Eto.Forms code!
To use an Eto.Forms control, you need to reference the platform assembly you are targeting (e.g Eto.WinForms.dll), which will provide a Control.ToNative() extension property, which returns the native control for the specified control:
// create eto control
var etoControl = new Eto.Forms.Panel();
// get native container for the control
System.Windows.Forms.Control myEtoControlAsWinForms = eto.ToNative(true); // true when adding to a native control directly
// add native container to a native control
var myWinFormsControl = new System.Windows.Forms.Panel();
myEtoControlAsWinForms.DockMode = System.Windows.Forms.DockMode.Fill;
myWinFormsControl.Controls.Add(myEtoControlAsWinForms);
## Using native controls within Eto.Forms
Coming soon!