This is my model:
public class ObsModel : BindableBase
{
private String _ObsName = string.Empty;
public string ObsName
{
get { return this._ObsName; }
set { this.SetProperty(ref this._ObsName, value); }
}
private String _ObsColor = string.Empty;
public string ObsColor
{
get { return this._ObsColor; }
set { this.SetProperty(ref this._ObsColor, value); }
}
private String _ObsValue = string.Empty;
public string ObsValue
{
get { return this._ObsValue; }
set { this.SetProperty(ref this._ObsValue, value); }
}
}
I can then populate my model using this object.
ObservableCollection<ObsModel> LastObsResults = new ObservableCollection<ObsModel>();
But how can I remove a particular collection if I have for example the observation name as a string variable by using the code below?
LatsObsResults.Remove( What DO I PUT HERE);
You remove an object from the collection by passing in the object to remove. This can be done through Linq like so:
LastObsResults.Remove(LastObsResults.FirstOrDefault(obs => obs.ObsName == name));