Frage

Hey,

short question:

I want to notify my ui, so my guard method is invoked once again.. But unfortunately I get an syntax-error using this statement:

NotifyOfPropertyChange(() => CanLogin);

My class inherits PropertyChangedBase.

The error message:

The type arguments for method 'void Calidburn.Miro:PropertyChangedBase.NotifyOfPropertyChange<TProperty>(Expression<Func<TProperty>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

Do I miss some overload or is something else wrong? What else could be the problem?

War es hilfreich?

Lösung

Based on the code you posted in your comment, I think your problem is that the NotifyPropertyChanged method is expecting you to pass a property, rather than a method.

So you'd want something like:

public bool CanLogin 
{ 
    get
    {
        return !string.IsNullOrEmpty(Ip) && !string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Port); 
    }
}

I was going to write something about Expression<Func<TProperty>> to help explain the error message, but this answer does a fantastic job: Why would you use Expression<Func<T>> rather than Func<T>?

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top