Skip to content

SelectionChangedCommandParameter is evaluated before SelectedItem updates in .NET 11 #1165

@SuthiYuvaraj

Description

@SuthiYuvaraj

Describe the bug

When using CommunityToolkit-generated commands with CollectionView, the SelectionChangedCommandParameter is evaluated before the SelectedItem binding is updated in .NET 11.
This behavior differs from .NET 10, where the bound SelectedItem was already updated when the command executed.
As a result, commands that rely on ViewModel properties (for example, SelectedItem) receive null or stale values.

  • The command executes before the SelectedItem binding is updated.
  • SelectionChangedCommandParameter is null or contains the previous value.
  • This breaks scenarios that rely on ViewModel-bound properties inside the command.

Regression

8.0.3

Steps to reproduce

Run the attached sample.
Tap/select an item in the CollectionView.
Observe that SelectionChangedCommand is invoked.
Inspect the value of SelectionChangedCommandParameter.

Expected behavior

SelectionChangedCommandParameter should receive the updated selected item (or the updated ViewModel property) when the command executes.

Screenshots

No response

IDE and version

VS 2022

IDE version

No response

Nuget packages

  • CommunityToolkit.Common
  • CommunityToolkit.Diagnostics
  • CommunityToolkit.HighPerformance
  • CommunityToolkit.Mvvm (aka MVVM Toolkit)

Nuget package version(s)

8.0.4

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛An unexpected issue that highlights incorrect behaviormvvm-toolkit 🧰Issues/PRs for the MVVM Toolkitneeds author feedback 📝This issue or PR needs a reply from the author

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions