One Monkey
One Monkey

Reputation:

Can I pass data from Winforms to WPF Control?

I have a winforms app but I would like to introduce a WPF user control into the app as a taster for further WPF implementation.

This control needs to receive from its Host a single piece of information, a string. How can I pass this down from the Winforms app to the hosted control?

Or, indeed, can I?

Upvotes: 2

Views: 2437

Answers (2)

alex
alex

Reputation: 76005

It is possible. Extend your WPF User Control with methods to set whatever data you want and call them from within WinForms application. See this article for example.

Upvotes: 2

Arsen Mkrtchyan
Arsen Mkrtchyan

Reputation: 50752

Assign properties of wpf control after creating an instance and before giving the reference to host's childes

WpfUserControl ctrl = new WpfUserControl();
ctrl.Data = passedData;
ElementHost1.Child = ctrl;

Upvotes: 5

Related Questions