-
Notifications
You must be signed in to change notification settings - Fork 116
New ItemClickBehavior for ListView/GridView.ItemClick #187
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
base: main
Are you sure you want to change the base?
Conversation
I'm surprised this wasn't here already actually! Having created this on multiple occasions for various projects, I'd find this addition welcoming. |
Can anyone help with the CI? I'm not super familiar with the setup of this repo/CI, but the The CI is failing with some rather weird errors that seem a bit suspicious, considering the new behavior literally is a single self-contained class only using standard types from the BCL and the various built-in UWP types. I mean, like:
I'm a bit confused here 🤔 |
@Sergio0694 it looks like the issue is to do with the SDKs not being available and it's building with VS2019 looking at the logs from appveyor. At the top,
Then everything after that point is just errors 🤔 Looking at the build history too shows it's been failing for some time. It almost looks like there was a change with the CI in appveyor to move from VS2017 (where it was previously building). Also appears that the change you described to get it to work was exactly what had been done on the preview WinUI branch too (4c12ffe) by @DVaughan |
Hey @jamesmcroft - thanks for looking into this! I guess we'll just need to hear from someone from the behaviors team about how to proceed here then 😄 |
@mgoertz-msft what should be done here? |
Feature: new
ItemClickBehavior
typeSummary
This PR introduces a new
ItemClickBerhavior
type, targetingListViewBase
(so it can be used with bothListView
andGridView
), which allows to easily invoke a command when an item is clicking, and also to pass the clicked item directly as parameter.This results in more compact and efficient code than using an
EventTriggerBehavior
+ an invoke command behavior, and it allows to directly receive the clicked item as argument to the command, which would've otherwise not been possible.Here's a usage example:
The target command will be invoked when an item is clicked and will receive the
ItemClickEventArgs.ClickedItem
instance directly. This is especially useful when using eg. theRelayCommand<T>
type (see CommunityToolkit/WindowsCommunityToolkit#3230), as you can then also specify the target type of a clicked item and have the command wrap a model directly in the viewmodel: