Ejemplo n.º 1
0
        /// <summary>
        /// Resets the Value to the value provided by DefaultValue
        /// </summary>
        /// <param name="raise">If True, raise OnPropertyChanged event and call the OnValueChanged callback</param>
        public void ResetToDefaultValue(bool raise)
        {
            var oldValue = Value;

            PropertyMethods.LoadValue(_value, DefaultValue);
            if (raise)
            {
                RaiseOnPropertyChanged(Owner, "Value");
            }
            if (raise)
            {
                ExecuteOnValueChanged(oldValue, Value);
            }
            IsDirty = false;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets the property value
        /// </summary>
        /// <param name="value">The new property value</param>
        /// <param name="callerMemberName">For logging purposes; it's not necessary to set</param>
        protected override void SetValue(object value, [CallerMemberName] string callerMemberName = "")
        {
            bool cancel = false;

            RaisePropertyValueChanging(Value, (TValue)value, ref cancel);
            if (!cancel)
            {
                var oldValue = _value.Value;
                PropertyMethods.SetValue <TValue>(_value, (TValue)value, null);
                IsDirty = true;
                RaisePropertyValueChanged(oldValue, (TValue)value);
                //call the base implementation to raise the OnPropertyChanged
                base.SetValue(value, callerMemberName);
                //now call our callback
                ExecuteOnValueChanged(oldValue, (TValue)value);
                _mre.Set();
                _mre.Reset();
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Loads Value without raising events or calling the OnValueChanged callback
 /// </summary>
 /// <remarks>Calling LoadValue sets IsDirty to false</remarks>
 /// <param name="value">The new value</param>
 public void LoadValue(TValue value)
 {
     PropertyMethods.LoadValue(_value, value);
     IsDirty = false;
 }