You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When set DataContext to a control type, binding command to method in the control will cause InvalidCastException for Android, but which works ok on Windows (Linux and iOS hasn't tested).
Versions:
Avalonia: 11.2.3
Avalonia.Android: 11.2.3
.Net: 9
Android Platform API level: 35
Content of the exception:
System.InvalidCastException: Specified cast is not valid.
at CompiledAvaloniaXaml.XamlIlTrampolines.Sample:Sample.Views.MyBorder+Test_0!CommandExecuteTrampoline(Object , Object )
at Avalonia.Data.Core.ExpressionNodes.MethodCommandNode.Command.Execute(Object parameter)
at Avalonia.Controls.Button.OnClick()
at Avalonia.Controls.Button.OnPointerReleased(PointerReleasedEventArgs e)
at Avalonia.Input.InputElement.<>c.<.cctor>b__32_9(InputElement x, PointerReleasedEventArgs e)
at Avalonia.Interactivity.RoutedEvent1.<>c__DisplayClass1_01[[Avalonia.Input.PointerReleasedEventArgs, Avalonia.Base, Version=11.2.3.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b],[Avalonia.Input.InputElement, Avalonia.Base, Version=11.2.3.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b]].g__Adapter|0(Object sender, RoutedEventArgs e)
at Avalonia.Interactivity.RoutedEvent.<>c__DisplayClass23_0.b__0(ValueTuple2 args) at Avalonia.Reactive.AnonymousObserver1[[System.ValueTuple2[[System.Object, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Avalonia.Interactivity.RoutedEventArgs, Avalonia.Base, Version=11.2.3.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b]], System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].OnNext(ValueTuple2 value)
at Avalonia.Reactive.LightweightObservableBase1[[System.ValueTuple2[[System.Object, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Avalonia.Interactivity.RoutedEventArgs, Avalonia.Base, Version=11.2.3.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b]], System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].PublishNext(ValueTuple2 value) at Avalonia.Reactive.LightweightSubject1[[System.ValueTuple2[[System.Object, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Avalonia.Interactivity.RoutedEventArgs, Avalonia.Base, Version=11.2.3.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b]], System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].OnNext(ValueTuple2 value)
at Avalonia.Interactivity.RoutedEvent.InvokeRaised(Object sender, RoutedEventArgs e)
at Avalonia.Interactivity.EventRoute.RaiseEventImpl(RoutedEventArgs e)
at Avalonia.Interactivity.EventRoute.RaiseEvent(Interactive source, RoutedEventArgs e)
at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e)
at Avalonia.Input.TouchDevice.ProcessRawEvent(RawInputEventArgs ev)
at Avalonia.Input.InputManager.ProcessInput(RawInputEventArgs e)
at Avalonia.Controls.TopLevel.<>c.b__145_0(Object state)
at Avalonia.Threading.Dispatcher.Send(SendOrPostCallback action, Object arg, Nullable`1 priority)
at Avalonia.Controls.TopLevel.HandleInput(RawInputEventArgs e)
at Avalonia.Android.Platform.Specific.Helpers.AndroidMotionEventsHelper.DispatchMotionEvent(MotionEvent e, Boolean& callBase)
at Avalonia.Android.Platform.SkiaPlatform.TopLevelImpl.ViewImpl.DispatchTouchEvent(MotionEvent e)
at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_(IntPtr jnienv, IntPtr native__this, IntPtr native_e) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net9.0/android-35/mcw/Android.Views.View.cs:line 16430
at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_Z(_JniMarshal_PPL_Z callback, IntPtr jnienv, IntPtr klazz, IntPtr p0) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 132
To Reproduce
Create a solution with template: Avalonia Cross Platform Application
Supheria
changed the title
If set x:DataType to a control type, binding command to method in the control is not invalid for Android
If set x:DataType to a control type, binding command to method in the control is invalid for Android
Dec 25, 2024
@oli-g-sk your issue seems to be completely unrelated and I doubt it is even a bug in Avalonia. Please open a discussion and share the entire AvaloniaApplication2 test project without bin and obj folders there.
Describe the bug
When set DataContext to a control type, binding command to method in the control will cause InvalidCastException for Android, but which works ok on Windows (Linux and iOS hasn't tested).
Versions:
Content of the exception:
To Reproduce
Create a solution with template: Avalonia Cross Platform Application
MainView.cs
MainView.axml
MyBorder.cs
Expected behavior
Debug outputs "test invoked" same as on Windows.
Avalonia version
11.2.3
OS
Android
Additional context
No response
The text was updated successfully, but these errors were encountered: