AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.3k stars 2.19k forks source link

Host WinForms or WPF controls #2379

Closed georgiuk closed 3 years ago

georgiuk commented 5 years ago

Hi, Is it possible to host windows forms or WPF controls in avalonia? I know the opposite is possible. If not would you think would be difficult to implement? Kostas

kekekeks commented 5 years ago

We currently don't have a way to efficiently host a native child window in our windows.

Even if we did there would be the airspace problem. We can seamlessly embed our own content to WinForms and WPF because we can draw into WinForms or WPF controls. Unfortunately we can't implement a custom HwndSource which would allow us to make WPF draw it's content into Avalonia control.

mmakdis commented 5 years ago

Wouldn't this pretty much ruin the fact that Avalonia is cross-platform?

kekekeks commented 5 years ago

@dizaztor Integration with existing technologies is needed for step-by-step migration. It's hard to port the entire app at once, so it might be desired to port one part at a time.

StefanKoell commented 3 years ago

I also have this issue. I would love to take a closer look at AvaloniaUI with paid support and all that but migrating my existing app comes with some challanges. For example, I'm dependent on some 3rd party ActiveX or WinForms control which I can't replace with anything else. A way to host something like that would be a requirement for my project. Is there something built-in, already available or on the horizon?

kekekeks commented 3 years ago

NativeControlHost is available in 0.10.0. See https://github.com/AvaloniaUI/Avalonia/tree/1a39210febf92e9e87b3ebacca9b56d99e660913/samples/interop/NativeEmbedSample for example usage.

danwalmsley commented 3 years ago

https://github.com/AvaloniaUI/Avalonia/tree/master/samples/interop/NativeEmbedSample

vchelaru commented 2 years ago

@georgiuk you said:

I know the opposite is possible.

Can you point me to a link on how to do this (how to host avalonia in wpf?)