/// <summary> /// Internals the property change. /// </summary> /// <param name="modelInstance">The model instance.</param> /// <param name="newValue">The new value.</param> /// <param name="message">The message.</param> private async void InternalPropertyChange(BindableBase modelInstance, TProperty newValue, string message) { //find out there will be a changing by makesure they are not equal var changing = (this.EqualityComparer != null) ? !this.EqualityComparer(newValue, _value) : !Object.Equals(newValue, _value); if (!changing) { return; } //fire changing event ask if anyone against changing var changingArg = new ValueChangingEventArgs <TProperty>(message, _value, newValue); modelInstance.RaisePropertyChanging(changingArg); var oldvalue = _value; _value = newValue; await Task.Yield(); if (changingArg.Cancellation.IsCancellationRequested) { _value = oldvalue; return; } if (ValueChanging != null) { ValueChanging.Invoke(this, changingArg); await Task.Yield(); if (changingArg.Cancellation.IsCancellationRequested) { _value = oldvalue; return; } } if (NonGenericValueChanging != null) { NonGenericValueChanging.Invoke(this, changingArg); await Task.Yield(); if (changingArg.Cancellation.IsCancellationRequested) { _value = oldvalue; return; } } ValueChangedEventArgs <TProperty> changedArg = new ValueChangedEventArgs <TProperty>(message, oldvalue, newValue); modelInstance.RaisePropertyChanged(changedArg); ValueChanged?.Invoke(this, changedArg); NonGenericValueChanged?.Invoke(this, changedArg); }
/// <summary> /// Raises the <see cref="ValueChanging"/> event with the given parameters. /// </summary> /// <param name="args">The arguments of the event.</param> protected void NotifyContentChanging(MemberNodeChangeEventArgs args) { PrepareChange?.Invoke(this, args); ValueChanging?.Invoke(this, args); }
private void OnValueChanging(object sender, MemberNodeChangeEventArgs e) { ValueChanging?.Invoke(sender, e); }
/// <summary> /// Raises the ValueChanging event /// </summary> /// <param name="oldValue">The old property value</param> /// <param name="newValue">The expected new property value</param> /// <param name="cancel">Set to True to cancel the property change</param> protected virtual void RaisePropertyValueChanging(TValue oldValue, TValue newValue, ref bool cancel) { ValueChanging?.Invoke(Owner, oldValue, newValue, ref cancel); }
/// <summary> /// 値変更前イベントを発生させる。 /// </summary> /// <param name="e">ValueChangingEventArgs</param> protected virtual void InvokeValueChanging(ValueChangingEventArgs e) { ValueChanging?.Invoke(this, e); }
protected void RaiseValueChanging(object newValue) { ValueChanging?.Invoke(this, new ValueChangingEventArgs(newValue)); }
protected virtual void OnValueChanging(object sender) { ValueChanging?.Invoke(sender); }