Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8689169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:34:27+00:00 2026-06-12T23:34:27+00:00

While copying code for RelayCommand from Josh Smith article I copied following code public

  • 0

While copying code for RelayCommand from Josh Smith article I copied following code

public event EventHandler CanExecuteChanged
{
    add { CommandManager.RequerySuggested += value; }
    remove { CommandManager.RequerySuggested -= value; }
}

Then after reading this answer on SO I also copied in my class following code from DelegateCommand class of Prism.

protected void NotifyCanExecuteChanged()
{
    if (CanExecuteChanged != null)
    {
        CanExecuteChanged(this, EventArgs.Empty);
    }
}

But his gives me an error in NotifyCanExecuteChanged method

The event ‘CanExecuteChanged’ can only appear on the left hand side of += or -=

This error is not coming if I remove the add and remove overload from event. Can someone please help me understand the reason behind this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:34:28+00:00Added an answer on June 12, 2026 at 11:34 pm

    With a field-like event (which is the name for the simple form without add/remove, then when you do if(CanExecuteChanged != null) or CanExecuteChanged(this, ...), the CanExecuteChanged is referring to the backing field, which is a delegate field of type EventHandler. You can invoke a delegate field. However, that is not the case in your example, because there is no obvious thing to invoke. There certainly isn’t a local field, and the forwarded event (CommandManaged.RequerySuggested) does not intrinsically expose any “invoke” capability.

    Basically, for that to work you would need access to an invoke mechanism. Most commonly, I would expect that to take the form of:

    CommandManager.OnRequerySuggested();
    

    but if there is a method that invokes this event (and there doesn’t need to be), it could be called anything.

    (the On* is a common pattern for a “raise this event” API, doubly-so if it is polymorphic)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to reuse code from another project, but while copying the classes
My problem is I got following encoding error while copying data from csv files
I've got the following code in my headers to load a font from Google's
For testing code I'm copying data from a live database to a test database
I’m having some difficulties while trying to consume an unmanaged-code dll from my application
So, copying the code from Introduction to Compiler Construction in Unix I wind up
I have quite a strange problem , While copying one WidgetCollection from one FlowPanel
I try to inline my VM by copying code segments from C code between
I have this copying code from infile to outfile, the problem is that there
While debugging and keep pressing F5, if the source code does not exist, eclipse

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.