开发者

Can I pass data from Winforms to WPF Control?

开发者 https://www.devze.com 2022-12-08 21:34 出处:网络
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.

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?


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;


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号