Пример #1
0
        private void InternalValidateProperty(string propertyName, object value)
        {
            var  results = new List <ValidationResult>();
            bool isValid = Validator.TryValidateProperty(value, new ValidationContext(this, null, null)
            {
                MemberName = propertyName
            }, results);

            if (isValid)
            {
                RemoveErrors(propertyName);
            }
            else
            {
                AddErrors(propertyName, results);
            }
            NotifyErrorsChanged(propertyName);
            BindingHelper.InternalNotifyPropertyChanged("HasErrors", this, propertyChanged);
        }
Пример #2
0
        /// <summary>
        /// Restores original
        /// </summary>
        public void CancelEdit()
        {
            // Return if BeginEdit not called first
            if (Copy == null)
            {
                return;
            }

            // Point entity to original
            Model = Original;

            // Clear copy
            Copy = null;

            // Notify IsEditing, IsDirty
            BindingHelper.InternalNotifyPropertyChanged("IsEditing",
                                                        this, base.propertyChanged);
            BindingHelper.InternalNotifyPropertyChanged("IsDirty",
                                                        this, base.propertyChanged);

            // Post-processing
            OnCancelEdit();
        }
Пример #3
0
 /// <summary>
 /// Allows you to specify a lambda for notify property changed
 /// </summary>
 /// <typeparam name="TResult">Property type</typeparam>
 /// <param name="property">Property for notification</param>
 protected virtual void NotifyPropertyChanged <TResult>
     (Expression <Func <TModel, TResult> > property)
 {
     // Fire PropertyChanged event
     BindingHelper.NotifyPropertyChanged(property, this, propertyChanged, dispatcher);
 }