I have below class -
public class Myclass : INotifyPropertyChanged
{
public Action FetchFoo()
{
var ctx = SynchronizationContext.Current;
return() => Task.Factory.StartNew(()=>
{
_isLoading = true;
businesslogic(ctx);
_isLoading = false;
});
}
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if(handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
private bool _isLoading = false;
public bool IsLoading
{
get{ return _isLoading;}
set
{
_isLoading = value;
OnPropertyChanged("IsLoading");
commandManager.RefreshCommand.CanExecute();
}
}
}
The issue here is set method is never getting called. (Though it is setting the valus of IsLoading Properly). Even if I put a break point here, it doesn't come to set method. OnPropertyChanged() method I want to write few business logic which I am not able to. Can anyone put some insight what wrong I am doing here. Thanks!
CodePudding user response:
The method that has the setter is IsLoading, but you're never calling that. You should use
IsLoading = true;
instead of
_isLoading = true;