I have an interface Service which has a method GoTo
public interface Service
{
bool GoTo(string NextPage , object parameter);
}
I have a class A as follows
public class A
{
private Service serviceA;
//constructor of the class
public A(Service serviceB, ServiceManager serviceManager)
{
this.serviceA = serviceB;
}
public ObservableCollection<SampleObject> Example { get; } = new
ObservableCollection<SampleObject>()
{
new SampleObject() { Action= new DelegateCommand(() => this.serviceA.GoTo("NextPage", null))
},
};
}
I get an error on this saying that the keyword 'this' is not available in the current context. I have looked at A field initializer cannot reference the nonstatic field, method, or property and i can see that the error is due to the variable not being initialized in the constructor but in my case i do that . Any help in understanding this is better would be appreciated?