-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows support #7
Comments
second that, trying to implement it myself is a little overwhelming, because the used AvaloniaView is not implemented for windows, but oddly for all other platforms.
|
Avalonia for Windows is using Win32 API layer instead of UWP/WinUI one. You can try using UWP/WinUI APIs for embedding Win32 content. |
i created a draft PR #8 It's quite tough, i've done the obvious things. But since i added the desktop/win32 i get super strange compile errors. i didn't change anything in the xmlns.
Feel free to fork my PR and apply fixes. Stacktrace
|
@kekekeks why is the axaml-compiler trying to parse non-axaml files? I deduct, because the problem started when i included the avalonia.win32 nuget, that the culprit is somewhere in the targets/props of the Avalonia.Desktop or Avalonia.Win32 package. |
@maxkatz6 @emmauss @danwalmsley I'm really stuck here, can you help pls? I'm evaluating avalonia for a gradual migration from maui to avalonia. |
AFAIK one solution could be to relax ResolveView in the SourceGenerator to not throw a terminating exception, but to ignore (warn) if processing a imcompatible (non-avalonia) xaml-files was unsuccessful. |
i guess, this might be related too. |
@juwens Great to see someone looking into this. Thanks for your efforts 👍 |
Not sure how to fix that additional files problem, since Does Roslyn see custom MSBuild metatadata for AdditionalFiles? If so, we could update our targets to mark ones converted from AvaloniaXaml |
… the ava source gen issue AvaloniaUI#7 (comment)
It would simplify things a lot, if WinUI supported HwndHost or a similar "islands" approach at least. |
@maxkatz6 I’m still trying to implement it in a separate fork of the main avalonia repo. But I have a lot of question marks. For example: do you mean it’s literally impossible with the current state of WinUI? |
@maxkatz6 it seems to work the other way around: microsoft/microsoft-ui-xaml#2828 maybe we can host a WinUI App inside an avalonia App? 😬 |
Yeah, it should be easier. Creating a small WinUI window for each control to be hosted inside of Avalonia.
Just easier with HwndHost. HwndHost would handle pointers, inputs and others. We had similar integration for WPF before - https://github.com/AvaloniaUI/Avalonia/tree/release/0.10.22/src/Windows/Avalonia.Win32.Interop/Wpf. Except it used Direct2D backend, which is not an option anymore. |
@maxkatz6 big thanks for the detailed answer. |
if we have instructions to adjust csproj to have avaloniamauihybrid, aka use maui/use essentials and etc only when compiling android and ios but not having maui nor maui things when compiling windows or brwser then we can have an solution with windows and browser implemantantion of some feature and use maui essentials in ios and android only. can someone help with this ? I tried but i have failed... |
I kind of agree. But since we are a line of business app and we need to be backward compatible so our customers can keep working, we need
AvaloniaUI ticks all of the (many other) boxes, but not being able to support barcodes is just a game stopper. Regarding the platform APIs: But the QR Code Scanner still bogs me. So we would need:
Since @maxkatz6 you seem to be an expert in windows interoperability:
|
It looks like you only need https://github.com/Redth/ZXing.Net.Maui/tree/main/ZXing.Net.MAUI which seems to generate bitmaps or receive bitmaps from a platform-specific implementation. So in the end you need to add an Avalonia version of these: https://github.com/Redth/ZXing.Net.Maui/tree/main/ZXing.Net.MAUI.Controls/Controls |
Ok, so we found a project called FlashCap that supports video frame capturing on Avalonia (Desktop). And it turns out, it was quite easy to modify their sample to get our QR code scanner to work, since they all rely on SkiaSharp. So now, the only thing left is: Being able to reference AvaloniaMauiHybrid and still being able to build on windows... I'll give it a try |
The biggest problem of MAUI Windows is that MAUI uses WinUI framework, while Avalonia works on a lower level of Win32 APIs. And WinUI has a bad reputation of being very unfriendly with any kinds of integrations. Using platform APIs, on the other hand, doesn't require that. No need to embed any controls. If you need to use Maui.Essentials - just reference the package. https://www.nuget.org/packages/Microsoft.Maui.Essentials/.
In general, Maui.Essentials is a nice abstraction, making it easier to use platform specific code. Just like Avalonia itself has some APIs, like clipboard of file dialogs. Is there any specific you want to Avalonia to do here? |
Add target framework conditions in your csproj.
Or, if your projects are separated by platform (Project.Android, Project.iOS, Project.Desktop...), then don't need any conditions, just include package only in android+ios projects. |
@maxkatz6 thank you for your valuable insights - honestly :-) However, I already tried this approach, and as soon as I include any of those target frameworks required for Maui.Essentials for Windows, the following happens: |
It might be possible now with experimental WinUI API - ContentExternalOutputLink Although it would require some sort of input redirection. |
Could Avalonia use XAML Islands (added in WinAppSDK 1.4) to host WinUI content inside a Win32 application? |
Hi, this is awesome, thanks for sharing! Is it possible to add Windows support to the sample too?
The text was updated successfully, but these errors were encountered: