Skip to content
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

Can't get commands to work without MVVM #176

Closed
mtanml opened this issue Apr 28, 2024 · 6 comments
Closed

Can't get commands to work without MVVM #176

mtanml opened this issue Apr 28, 2024 · 6 comments

Comments

@mtanml
Copy link

mtanml commented Apr 28, 2024

Excellent grid control, thank you! I'm just having an issue getting RowTappedCommand to fire. I'm not using MVVM, so my view is bound to the code behind with Binding = this.

Here's my grid definition:

<dg:DataGrid x:Name="grdResults" ItemsSource="{Binding Results}" SelectedItem="{Binding SelectedLoanType, Mode=TwoWay}" SelectionMode="Single" RowTappedCommand="{Binding ItemTappedCommand}" x:DataType="local:QualifyResultsView">

And the code behind:

public ICommand ItemTappedCommand { get; set; }
BindingContext = this;
ItemTappedCommand = new Command(ItemTapped);
private void ItemTapped(object item){ }

Are you able to assist? Thanks!

@symbiogenesis
Copy link
Collaborator

RowTappedCommand is one of the only parts of this library that I've not thought about, as it is a newer feature added by someone else.

I think your code looks fine to me, and it shouldn't matter whether you are using MVVM. Although, this control was clearly made with MVVM support in mind.

If you fork this repo and then modify the sample project to demonstrate the issue, that might help.

Also, make sure you are using the absolute latest version of this library, and the latest MAUI version.

@mtanml
Copy link
Author

mtanml commented Apr 29, 2024 via email

@symbiogenesis
Copy link
Collaborator

Another user has been reporting it, but the rest of us cannot replicate it:

#170

@symbiogenesis
Copy link
Collaborator

maybe do:

dotnet workload update

Almost seems like a "works on my machine" type of issue. Which is why I say.

But another user experienced a problem with the ItemSelected event, and switching to the RowTappedCommand is what fixed it for them. #173

You could try the reverse of that, and switch to the event.

@mtanml
Copy link
Author

mtanml commented Apr 29, 2024

Hi Edward,

Based on the comments in those other issues that you referred to, I rolled back to version 4.0.1 and the ItemSelected handler works perfectly in that version.

Thank you!

@mtanml mtanml closed this as completed Apr 29, 2024
@symbiogenesis
Copy link
Collaborator

When PR #178 lands, this will probably allow you to update without a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants