Hosting WPF controls in Winforms

2019-06-22 06:15发布

问题:

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;