コード例 #1
0
ファイル: ModelBase.cs プロジェクト: ewin66/XERP.NET
        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
ファイル: ModelBase.cs プロジェクト: ewin66/XERP.NET
 /// <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);
 }