My Application is developed using WinForms. Is it possible to host the WPF DataGrid
, Button
, ListBox
, ComboBox
etc in WinForms User Controls?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Yes, it's possible using the ElementHost
control in Winforms and hosting WPF content inside of it.
回答2:
I would not mix WinForm and WPF unless absolutely necessary. Though, Microsoft has provided the way to use WPF control in WinForm and vice-versa but it doesn't always give good result. WF and WPF renders the controls in different ways and you may face multiple issues including performance and UI flickering depending on the way they have been used.
If you really want to use WPF control in WF then use ElementHost control.
ElementHost.Child = wpfControl;