public void RemoveWarning(Warning warning) { try { Warnings.Remove(warning); WarningsChanged?.Invoke(this); } catch (Exception e) { Debug.WriteLine(e); } }
public void AddWarning(Warning newWarning) { try { Warnings.Add(newWarning); WarningsChanged?.Invoke(this); } catch (Exception e) { Debug.WriteLine(e); } }
/// <summary> /// Notifies all listeners that the warnings for the specified property have changed. If the /// <paramref name="propertyName"/> is <c>null</c> or <see cref="string.Empty"/>, the business /// errors will be updated. /// </summary> /// <param name="propertyName">Name of the property.</param> /// <param name="notifyHasWarnings">if set to <c>true</c>, the <see cref="HasWarnings"/> property will be notified as well.</param> private void NotifyWarningsChanged(string propertyName, bool notifyHasWarnings) { if (string.IsNullOrEmpty(propertyName)) { RaisePropertyChanged(WarningMessageProperty); WarningsChanged.SafeInvoke(this, new DataErrorsChangedEventArgs(string.Empty)); } else { RaisePropertyChanged(this, new PropertyChangedEventArgs(propertyName), false, true); WarningsChanged.SafeInvoke(this, new DataErrorsChangedEventArgs(propertyName)); } if (notifyHasWarnings) { RaisePropertyChanged("HasWarnings"); } }