Avalonia Xamarin Forms Hybrid #11547
Replies: 1 comment
-
Embedding Avalonia content into native iOS/Android views is a supported scenario, but is currently not well-tested. It might have some lifecycle management issues in cases when controls go out of view. We also allocate a GPU surface per toplevel view, so complex layouts might suffer from increased resource consumption. The recommended way is to write big portions of the UI and embed entire Avalonia views rather than individual controls. Regarding allocating resources on a forms integration: while it indeed sounds like a good migration path from Xamarin.Forms to Avalonia, we are currently focused on delivering 11.0, so don't expect us to work on anything else in the next month or two. |
Beta Was this translation helpful? Give feedback.
-
I have seen the Avalonia Maui Hybrid. As for me, it is a nice idea to have some pixel-perfect components on every platform and have the ability to embed native stuff when we need it.
The Xamarin Forms end of life next year, so effectively, I would be dead soon. The MAUI is still dead, and it is unclear when we can call it "alive."
I am working on a big Xamarin Forms application and think that it would be nice to have something like Avalonia Xamarin Forms Hybrid. It can be a nice way to upgrade existing Xamarin Forms applications. You can start slowly replacing page by page, component by component, with Avalonia controls when possible. In the end, you would have mostly Avalonia controls and some native components wired up via Xamarin Forms. When the time comes, you can switch to Avalonia MAUI Hybrid, fix issues with native components, and you are ready to go. It is still some work to do, but it is much easier than stopping active development and digging through compilation errors for a month to find out that MAUI is still broken. It allows you to continue to work on existing app and prepare for upgrades in the future.
It did some experiments with Avalonia Xamarin Forms Hybrid. Basically, I replicated what you did with MAUI but did it for Xamarin. It is not perfect. Components may flicker and disappear and it works only on Android.
During testing, I noticed that performance looks much better. If Xamarin Forms can take up to 800ms to render. Avalonia does it within 400ms. It is without any optimization. AvaloniaHost is wrapped around every component. Looks like Avalonia Xamarin Forms Hybrid would be even a good thing for the application performance.
So, I am wondering, does the Avalonia team have any plans to support such a workflow?
From my side, I guess I will continue to dig around, and I think about what to do with existing issues, but it would be nice to know your plans in this regard.
The full source code is here: https://github.com/byme8/expAvaloniaXamarin
An example of usage can be found in MainPage.xaml.cs in XamarinForms main project.
Beta Was this translation helpful? Give feedback.
All reactions