CollectionViewSource.GetDefaultView(DGD_UserList.ItemsSource).Refresh();
this works once i added this
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi All,
My Delete and add methods work fine, the Update is calling the HTTPPut and changing the data but i cant get the WPF form to update the same way i have been updating with add and delete.
My class is implementing INotifyPropertyChanged and i have the OnPropertyChanged method.
is there a better way to update the observable collection for add and delete that will fix update?
Thanks
Madaxe
//----------------------------------------------------------
protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
//----------------------------------------------------------
public void UpdateContinent(string iNewContinentName, int iContinentObjectId)
{
Task<ContinentModel> TaskContinentModel = this.UpdateExistingContinent(iNewContinentName, iContinentObjectId);
ObservableCollection<ContinentModel> NewContinentModels = _ContinentModels;
ContinentModel UpdatedContinentModel = TaskContinentModel.Result;
NewContinentModels.Where(w => w.objectID == UpdatedContinentModel.objectID).ToList().ForEach(i => i.continentName = iNewContinentName);
this.ContinentModels = NewContinentModels;
}
private async Task<ContinentModel> UpdateExistingContinent(string iNewContinentName, int iContinentObjectId)
{
ContinentModel ReturnContinentModel = null;
//----------------------------------------------------------
public void CreateContinent(string iContinentName)
{
Task<ContinentModel> TaskContinentModel = this.CreateNewContinent(iContinentName);
ObservableCollection<ContinentModel> NewContinentModels = _ContinentModels;
NewContinentModels.Add(TaskContinentModel.Result);
this.ContinentModels = NewContinentModels;
}
private async Task<ContinentModel> CreateNewContinent(string iContinentName)
{
ContinentModel ReturnContinentModel = null;
//----------------------------------------------------------
CollectionViewSource.GetDefaultView(DGD_UserList.ItemsSource).Refresh();
this works once i added this
Hi, change your update method (assign !)
public void UpdateContinent(string iNewContinentName, int iContinentObjectId)
{
Task<ContinentModel> TaskContinentModel = this.UpdateExistingContinent(iNewContinentName, iContinentObjectId);
ObservableCollection < ContinentModel> NewContinentModels = _ContinentModels;
ContinentModel UpdatedContinentModel = TaskContinentModel.Result;
this.ContinentModels = NewContinentModels.Where(w => w.objectID == UpdatedContinentModel.objectID).ToList().ForEach(i => i.continentName = iNewContinentName);
}