简体   繁体   中英

WPF Error in routine

I had this subroutine code (See below) working just fine until an hour ago while testing.

NotifyOfPropertyChange(() => TestResults); triggers the error:

"Cannot convert lambda expression to type 'string' because it is not a delegate type"

I have googled around, and most solutions suggest adding "using System.Linq". I have done this as well as "using System.Data.Entity". Both of these are greyed out in Visual Studio suggesting that they are not used, and the error still persists.

I'm new to using WPF linked to subroutines, so I'm not entirely sure what it is doing, but like I said its been working fine, and I have another similar program where there is no error. Both have the same references and usings, and my other program doesn't even have "using System.Linq"

I'm sure its something stupid I'm missing. Thanks

  public string TestResults
    {
        get { return _testResults; }

        set
        {
            _testResults = value; 
            NotifyOfPropertyChange(() => TestResults);
        }
    }

Looks like you implement the interface INotifyPropertyChanged and should fire the PropertyChanged event by providing the name of the property. So I guess you can just call NotifyOfPropertyChange("TestResults") and it will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM