Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 21, 2025

Summary

Addresses issue #[issue_number] by clarifying that ICommand.CanExecuteChanged must be raised manually in .NET MAUI, unlike some UI frameworks (such as WPF) that automatically detect changes.

Problem

The existing documentation was ambiguous about whether ICommand.CanExecuteChanged must be raised manually or if the framework automatically calls CanExecute when conditions change. This caused confusion for developers coming from WPF, where dependency property changes automatically trigger CanExecute re-evaluation.

Changes

This PR makes four targeted improvements to docs/fundamentals/data-binding/commanding.md:

  1. Line 54 - Added explicit statement that "The event must be raised manually from within the viewmodel"

  2. Lines 56-57 - Added a prominent IMPORTANT note that:

    • Directly compares .NET MAUI to WPF behavior
    • Explicitly states that MAUI does NOT automatically detect when CanExecute might change
    • Clarifies developers must manually raise CanExecuteChanged or call ChangeCanExecute()
    • Explains when this should be done (when properties that CanExecute depends on are modified)
  3. Line 62 - Changed "fire the CanExecuteChanged event" to "manually fire the CanExecuteChanged event"

  4. Line 302 - Changed "A viewmodel should call" to "Your viewmodel must call" for stronger, more imperative language

Impact

  • Developers will now clearly understand the manual invocation requirement
  • The comparison to WPF helps developers transitioning from other frameworks
  • Multiple reinforcements throughout the document ensure the message is clear
  • Changes are minimal and surgical (1 file, +6/-3 lines)

Fixes #[issue_number]

Original prompt

This section details on the original issue you should resolve

<issue_title>Improvement Request: Clarify the use of ICommand.ChangeCanExecute() – Must it be called manually?</issue_title>
<issue_description>### Type of issue

Missing information

Description

When using WPF, the ICommand.CanExecute method is called by the framework when a dependency property changes.

However, the documentation page for MAUI Commanding seems to imply that the ICommand.CanExecuteChanged event must be raised manually for the ICommand.CanExecute method to be processed. This is not explicitly stated, though.

Please clarify whether the ICommand.CanExecuteChanged event must be raised manually or if the ICommand.CanExecute method is called automatically by the framework.

Page URL

https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/data-binding/commanding?view=net-maui-9.0

Content source URL

https://github.com/dotnet/docs-maui/blob/main/docs/fundamentals/data-binding/commanding.md

Document Version Independent Id

7d99bbf7-baf8-ce1d-1580-97f730028cd1

Platform Id

813ec11d-1bce-11b3-c0b7-15286b7ef973

Article author

@davidortinau

Metadata

  • ID: 7d99bbf7-baf8-ce1d-1580-97f730028cd1
  • PlatformId: 813ec11d-1bce-11b3-c0b7-15286b7ef973
  • Service: dotnet-mobile
  • Sub-service: dotnet-maui

Related Issues</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #3065


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.


Internal previews

📄 File 🔗 Preview link
docs/fundamentals/data-binding/commanding.md docs/fundamentals/data-binding/commanding

@learn-build-service-prod
Copy link

Learn Build status updates of commit f7b2919:

✅ Validation status: passed

For more details, please refer to the build report.

Co-authored-by: jfversluis <939291+jfversluis@users.noreply.github.com>
@learn-build-service-prod
Copy link

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 issues. Other issues are also a high priority. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod
Copy link

Learn Build status updates of commit e40182a:

✅ Validation status: passed

File Status Preview URL Details
docs/fundamentals/data-binding/commanding.md ✅Succeeded View (>=net-maui-8.0)

For more details, please refer to the build report.

@learn-build-service-prod
Copy link

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 issues. Other issues are also a high priority. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod
Copy link

Learn Build status updates of commit e40182a:

✅ Validation status: passed

File Status Preview URL Details
docs/fundamentals/data-binding/commanding.md ✅Succeeded View (>=net-maui-8.0)

For more details, please refer to the build report.

Copilot AI changed the title [WIP] Clarify usage of ICommand.ChangeCanExecute Clarify that ICommand.CanExecuteChanged must be raised manually in .NET MAUI Oct 21, 2025
Copilot finished work on behalf of jfversluis October 21, 2025 08:29
Copilot AI requested a review from jfversluis October 21, 2025 08:29
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

Successfully merging this pull request may close these issues.

Improvement Request: Clarify the use of ICommand.ChangeCanExecute() – Must it be called manually?

2 participants