How should I pass the view model to long press command?

Open
#582 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
25/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale

Research direction

Start with docs/maui/behaviors/touch-behavior.md and review the LongPressCommandParameter guidance in the linked article. Determine whether the collection item's view model can be passed through the documented binding, then clarify the article with the supported usage or limitation. Done means the page answers this long-press binding question without requiring issue-thread context.

Written by the indexing model from the issue text.

Description

dotnet-communitytoolkit/svc dotnet-maui-community-toolkit/subsvc Pri2
Type of issue

Missing information

Description

I'm using this behavior in a collection view to display images, and I want to handle the long press command.
LongPressCommandParameter="{Binding .}" However, the currently touched image's bound view model can't be passed to the command, where it shows null as the view model's value.

Page URL

https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/behaviors/touch-behavior?tabs=toucheffect-xaml%2Ctouchbehavior-xaml#properties

Content source URL

https://github.com/MicrosoftDocs/CommunityToolkit/blob/main/docs/maui/behaviors/touch-behavior.md

Document Version Independent Id

98a8e0a6-ef8e-7427-100f-7b4448e0ffce

Platform Id

28950eda-3f84-b0ac-bd2b-243cce75aa34

Article author

@bijington

Metadata
  • ID: 98a8e0a6-ef8e-7427-100f-7b4448e0ffce
  • PlatformId: 28950eda-3f84-b0ac-bd2b-243cce75aa34
  • Service: dotnet-communitytoolkit
  • Sub-service: dotnet-maui-community-toolkit
Dominant language
No language data
Stars
168
Forks
134
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MicrosoftDocs/CommunityToolkit

All issues in MicrosoftDocs/CommunityToolkit

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.