简体   繁体   English

例行WPF错误

[英]WPF Error in routine

I had this subroutine code (See below) working just fine until an hour ago while testing. 在测试之前,直到一个小时前,我的子例程代码(见下文)都可以正常工作。

NotifyOfPropertyChange(() => TestResults); NotifyOfPropertyChange(()=> TestResults); triggers the error: 触发错误:

"Cannot convert lambda expression to type 'string' because it is not a delegate type" “无法将lambda表达式转换为类型'字符串',因为它不是委托类型”

I have googled around, and most solutions suggest adding "using System.Linq". 我到处搜索,大多数解决方案建议添加“ using System.Linq”。 I have done this as well as "using System.Data.Entity". 我已经做到了这一点,以及“使用System.Data.Entity”。 Both of these are greyed out in Visual Studio suggesting that they are not used, and the error still persists. 这两个都在Visual Studio中显示为灰色,表明未使用它们,并且错误仍然存​​在。

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. 我是使用WPF链接到子例程的新手,所以我不确定它在做什么,但是就像我说的那样,它工作正常,并且我有另一个类似的程序,没有错误。 Both have the same references and usings, and my other program doesn't even have "using System.Linq" 两者都有相同的引用和用法,而我的其他程序甚至都没有“ 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. 看起来您实现了INotifyPropertyChanged接口,应该通过提供属性名称来触发PropertyChanged事件。 So I guess you can just call NotifyOfPropertyChange("TestResults") and it will work. 因此,我想您可以仅调用NotifyOfPropertyChange(“ TestResults”)即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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