xamarin / XamarinCommunityToolkit

The Xamarin Community Toolkit is a collection of Animations, Behaviors, Converters, and Effects for mobile development with Xamarin.Forms. It simplifies and demonstrates common developer tasks building iOS, Android, and UWP apps with Xamarin.Forms.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

App crash on button click in CollectionView Item

samhouts opened this issue · comments


Issue moved from dotnet/maui#17707


From @HobDev on Thursday, September 28, 2023 6:51:05 AM

Description

There are two buttons in a CollectionView ItemTemplate. Starangely the app crashes on clicking the first button. But strangely the app does not crash on clicking the second button.

Steps to Reproduce

Run the reproduction app. Try Clicking on the buttons in one of the CollectionView items.

Link to public reproduction project repository

https://github.com/HobDev/DotNet8MauiBugs/tree/CollectionViewDataIssue

Version with bug

8.0.0-rc.1.9171

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

7.0.92

Affected platforms

Windows

Affected platform versions

Windows SDK 10.0.19041.0

Did you find any workaround?

NO

Relevant log output

No response


Issue moved from dotnet/maui#17707


From @drasticactions on Thursday, September 28, 2023 2:45:40 PM

The error is

Message = "Parameter \"parameter\" (object) cannot be of type DotNet8MauiBugs.MainViewModel, as the command type requires an argument of type DotNet8MauiBugs.Venue. (Parameter 'parameter')"

So it's trying to pass in the View Model itself and not the parameter.

It actually throws when the app first runs before you click on it when it's initializing during "CanExecute" if you enable showing all exceptions. Trying it in MAUI net7.0, it does work. It throws in net8.0.

The big issue I see debugging this is that you're using two CommunityToolkit libraries, C# Markup and MVVM (For AsyncCommand, Relay, etc). While the same versions of those work with net7.0, I'm not sure if those have any influence into this and if they could be part of the problem you're having. It could be the binding API in C# Markup has a problem, or the AsyncCommand from MVVM is at fault? Or MAUI itself is passing in the wrong parameter. It's hard to tell based on how this is written.

If you could rewrite your code to only use pure MAUI APIs and can reproduce the issue (you don't have to use XAML, it can still be done in C#), that would help a lot.


Issue moved from dotnet/maui#17707

  • Please respond to @msftbot[bot].

From @msftbot[bot] on Thursday, September 28, 2023 3:11:02 PM

Hi @HobDev. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.


Issue moved from dotnet/maui#17707


From @nor0x on Thursday, September 28, 2023 8:07:46 PM

same!
Here is a repro
dotnet/maui#11956 (comment)


Issue moved from dotnet/maui#17707


From @samhouts on Thursday, September 28, 2023 8:55:02 PM

@nor0x I see you're also using the CommunityToolkit. Does it repro without that?


Issue moved from dotnet/maui#17707

  • Please respond to @msftbot[bot].

From @msftbot[bot] on Thursday, September 28, 2023 8:55:13 PM

Hi @HobDev. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.


Issue moved from dotnet/maui#17707


From @PureWeen on Thursday, September 28, 2023 10:53:58 PM

@HobDev can you test nightly? https://github.com/dotnet/maui/wiki/Nightly-Builds


Issue moved from dotnet/maui#17707


From @HobDev on Friday, September 29, 2023 6:31:01 AM

@PureWeen I added https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json in the Package Sources and Package Source Mapping of the Visual Studio 17.8.0 Preview 2.0. What should I do next to work with the nightly builds.


Issue moved from dotnet/maui#17707


From @HobDev on Friday, September 29, 2023 11:18:51 AM

@drasticactions I can confirm that that removing CommunityToolkit.Mvvm code resolves the issue. Can this issue be moved to the communitytoolkit repo.

While testing the code without CommunityToolkit.Mvvm and CommunityToolkit.Maui.Markup I catch another two bugs in the CollectionView which are reported here and here.


Issue moved from dotnet/maui#17707


From @nor0x on Friday, September 29, 2023 12:21:53 PM

@nor0x I see you're also using the CommunityToolkit. Does it repro without that?

will check that today 👍

EDIT:
i can now confirm that the crash doesn't occur without the CommunityToolkit - the root cause is probably somehwere in there

commented

@samhouts i think this is the wrong toolkit the issue was moved to. The crash seems to be caused by the CommunityToolkit.Mvvm package.

I have created the following issue over there
CommunityToolkit/dotnet#768

Closing this as per #1989 (comment)

@samhouts i think this is the wrong toolkit the issue was moved to. The crash seems to be caused by the CommunityToolkit.Mvvm package.

I have created the following issue over there CommunityToolkit/dotnet#768

WHOOPS! Sorry!! Thank you for fixing it. :)