Your
GetPersonInfo
method replaces the value of the
ListPersons
property with a new
IList<persrec>
. But you never raise the
PropertyChanged
event for that property, so the UI has no way of knowing that the collection has been replaced and it needs to update the grid.
The simplest solution is to raise the
PropertyChanged
event every time you change the property:
private IList<persrec> _listPersons = new List<persrec>();
public IList<persrec> ListPersons
{
get { return _listPersons; }
set { SetValue(ref _listPersons, value); }
}
private void SetValue<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
{
if (Equals(field, value)) return;
field = value;
NotifyPropertyChanged(propertyName);
}
private void NotifyPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}