Comments (10)
They share the same BindingContext/DataContext (QRCodeViewModel) theough.
Looks like DataContext isn't passed automatically.
But it's something that should be handled by this library.
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.
from avaloniamauihybrid.
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.
It's actually pretty similar to #20 issue.
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.
This way, you will have one MAUI XAML file with MAUI bindings, and another Avalonia XAML file that has first one as a content.
from avaloniamauihybrid.
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.
from avaloniamauihybrid.
Ideally, ZXing.Net.Maui should be re-ported to Avalonia using NativeControlHost, avoiding any other frameworks in between.
Hard to tell, how difficult it would be though. Technically, only camera view (a native control) needs to be wrapped into a NativeControlHost.
from avaloniamauihybrid.
yeah.. I aggree...
Regarding the preview overlapping everything else:
This seems to be a zxing.maui issue: If I run their demo project and try to put the camera preview into the middle row, it still overlaps.
Redth/ZXing.Net.Maui#4
The difference is, that AvaloniaMauiHybrid always renders all MAUI controls on top of everything else.
So I cannot render any avalonia controls on top of MAUI, correct?
Or is that a bug?
from avaloniamauihybrid.
On overlapping issue - the same would be with Avalonia-only port. Since native controls would be rendered on top of any avalonia content.
So I cannot render any avalonia controls on top of MAUI, correct?
So, yes. That's correct.
We have plans to support Popup (and Popup-related controls, like tooltip or flyout) to work on a separated layer though. It's already done on desktop (where it often is a separated window).
from avaloniamauihybrid.
Ok... makes sense.
Now, I updated the sample, so that the MAUI controls are in a separate MAUI View.
They share the same BindingContext/DataContext (QRCodeViewModel) theough.
But: Again the bindings do not have any effect on the MAUI controls.
Any thoughts?
from avaloniamauihybrid.
Apologies... I could have come to that conclusion myself... 😕
Thank you so much for all your valuable responses!
from avaloniamauihybrid.
Sorry - me again.
Now I tried out using ReactiveUI within MAUI controls.
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.
Everything works fine.
Now, i changed the ContentView
s to become ReactiveContentView<>
s and wanted to check if WhenActivated()
was ever called.
It turns out, that, again, the UI simply isn't rendered anymore.
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?
from avaloniamauihybrid.
Additionally this POC has two demo viewmodels:
PicturesViewModel
and QRCodeViewModel
.
To "navigate" between them, the MainViewModel
contains a ContentControl
and a command that just swaps the CurrentViewModel
Interestingly, navigating from the QRCodeView
to the PicturesView
causes the PicturesView
to (again) not be rendered at all:
Note: This also "works" when
- starting out with the
QRCodeViewModel
- or re-using the viewmodel instances
from avaloniamauihybrid.
Related Issues (16)
- macOS support
- Cannot run AvaloniaSample.Android HOT 12
- mauihybrid solution with all plataforms even without maui HOT 4
- stable nuget package HOT 3
- erros when compiling a blank solution Avalonia 11.06 with avalonia.maui and net8.0 and communitytoolkit.mvvm 8.2.2 HOT 6
- Error when using MAUI 8.0.6 HOT 4
- Maui embedding to Avalonia is not working with iOS HOT 8
- Java.Lang.IllegalArgumentException when try the sample HOT 2
- failed to request storage permission on android
- Using MAUI control causes build error: Error AVLN:0004 Avalonia: Unable to resolve suitable regular or attached property Name on type ZXing.Net.MAUI.Controls HOT 2
- Embedding AvaloniaView in a Maui Control from an AvaloniaApp HOT 1
- "Inverse" Avalonia Hybrid HOT 3
- Creating MAUI Handler from Avalonia and replacing maui native handlers HOT 1
- Question about native behavior on iOS HOT 1
- Windows support HOT 22
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avaloniamauihybrid.