Ok I have a ListView object which have a List as ItemSource and I\'d like to refresh the ItemSource whene
You can define a base view model and inherit it from INotifyPropertyChanged
public abstract class BaseViewModel : INotifyPropertyChanged
{
protected bool ChangeAndNotify(ref T property, T value, [CallerMemberName] string propertyName = "")
{
if (!EqualityComparer.Default.Equals(property, value))
{
property = value;
NotifyPropertyChanged(propertyName);
return true;
}
return false;
}
protected void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
then in your viewmodel (Ex. JM) will be inherit from BaseViewModel
and can create ObservableCollection List
Also your fields in ViewModel (Ex. JM) should implement like following:
public const string FirstNamePropertyName = "FirstName";
private string firstName = string.Empty;
public string FirstName
{
get { return firstName; }
set { this.ChangeAndNotify(ref this.firstName, value, FirstNamePropertyName); }
}
Hope this helps.