-
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
Using bindings for MAUI controls causes view to not be rendered at all #21
Comments
I don't know why it stops rendering the native control once binding is added, but I can say for sure that bindings aren't supported here. In Avalonia XAML, bindings and xName works well, since all the elements are AvaloniaObjects. The same goes with MAUI, it all works while all elements are known to MAUI framework. But when we mix different frameworks, it gets more complicated. You can't apply Avalonia.Binding to Maui.Control, since it doesn't inherit AvaloniaObject. Known workaround is to create a separated MAUI Page (or ContentView) and setup MAUI Bindings there. And in Avalonia XAML file only include this Page, without any extra bindings. |
And to be clear, while it's technically possible to add x:Name support for MAUI elements, I don't think we can support bindings on MAUI controls, without making adding MAUI as a first-class support to our XAML compiler. |
Ideally, ZXing.Net.Maui should be re-ported to Avalonia using NativeControlHost, avoiding any other frameworks in between. |
yeah.. I aggree... Regarding the preview overlapping everything else: The difference is, that AvaloniaMauiHybrid always renders all MAUI controls on top of everything else. |
On overlapping issue - the same would be with Avalonia-only port. Since native controls would be rendered on top of any avalonia content.
So, yes. That's correct. |
Ok... makes sense. But: Again the bindings do not have any effect on the MAUI controls. |
Looks like DataContext isn't passed automatically. A workaround to add (in QRCodeView.axaml.cs file): protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);
if (change.Property == DataContextProperty)
{
ProgressBarHost.Content!.BindingContext = change.NewValue;
BarcodeViewHost.Content!.BindingContext = change.NewValue;
}
} I also added BarcodeViewHost x:Name on the BarcodeView control host. |
Apologies... I could have come to that conclusion myself... 😕 |
Sorry - me again. For this, I started from the functioning prototype, where the MAUI UI parts are split out into their own views, so the MAUI bindings will work. Now, i changed the You can check out the branch here: https://github.com/gentledepp/POC_AvaloniaMauiApp01/tree/poc/settingmauipropsincodebehind So is this now a bug or again some known shortcoming? |
Hello... me again.
I am really sorry for bothering you guys, but I keep bumping into stuff.
I am currently trying to "copy" the implementation of the sample of ZXing Maui Barcode Reader
This is the view I try to move to Avalonia:
https://github.com/Redth/ZXing.Net.Maui/blob/main/BigIslandBarcode/MainPage.xaml
I managed to get it to work and actually get rendered.
1st attempt - keep everything in Maui
This worked on my android emulator (API 30)
but on my physical device (Huawei p30 pro) the UI remains empty
2nd attempt - use avalonia, and only wrap the barcodescanner in host
Now, it renders the barcode scanner view,
but as soon as I add any binding to those controls (even for bool values), the UI is not rendered anymore - the screen stays brown which is the background color of the Avalonia MainView
Am I missing something here?
Additionally, the rendering seems to not work correctly either:
The camera view should be shown inside the empty space here
But is actually rendered on top/covering everything else on the emulator:
It works though on my device... :-|
The text was updated successfully, but these errors were encountered: