public RowValidationError(
   ValidationRule ruleInError,
   Row rowInError,
   object errorContent,
   Exception exception )
 {
   m_ruleInError = ruleInError;
   m_rowInError = rowInError;
   m_errorContent = errorContent;
   m_exception = exception;
 }
Exemple #2
0
 /// <summary>
 /// ValidationError ctor
 /// </summary>
 /// <param name="ruleInError">rule that detected validation error</param>
 /// <param name="bindingInError">BindingExpression for which validation failed</param>
 /// <param name="errorContent">validation rule specific details to the error</param>
 /// <param name="exception">exception that caused the validation failure; optional, can be null</param>
 public ValidationError(ValidationRule ruleInError, object bindingInError, object errorContent, Exception exception)
 {
     if (ruleInError == null)
         throw new ArgumentNullException("ruleInError");
     if (bindingInError == null)
         throw new ArgumentNullException("bindingInError");
     
     _ruleInError = ruleInError;
     _bindingInError = bindingInError;
     _errorContent = errorContent;
     _exception = exception;
 }
Exemple #3
0
 /// <summary>Initializes a new instance of the <see cref="T:System.Windows.Controls.ValidationError" /> class with the specified parameters.</summary>
 /// <param name="ruleInError">The rule that detected validation error.</param>
 /// <param name="bindingInError">The <see cref="T:System.Windows.Data.BindingExpression" /> or <see cref="T:System.Windows.Data.MultiBindingExpression" /> object with the validation error.</param>
 /// <param name="errorContent">Information about the error.</param>
 /// <param name="exception">The exception that caused the validation failure. This parameter is optional and can be set to <see langword="null" />.</param>
 // Token: 0x06005986 RID: 22918 RVA: 0x0018B690 File Offset: 0x00189890
 public ValidationError(ValidationRule ruleInError, object bindingInError, object errorContent, Exception exception)
 {
     if (ruleInError == null)
     {
         throw new ArgumentNullException("ruleInError");
     }
     if (bindingInError == null)
     {
         throw new ArgumentNullException("bindingInError");
     }
     this._ruleInError    = ruleInError;
     this._bindingInError = bindingInError;
     this._errorContent   = errorContent;
     this._exception      = exception;
 }
Exemple #4
0
		/// <summary>
		/// Initializes a new instance of the <see cref="TextEditingAdorner"/> class.
		/// </summary>
		/// <param name="adornedElement">The adorned text block element.</param>
		/// <param name="initialText">The text that should initially be showed.</param>
		/// <param name="textBoxStyle">The style for the text box that is used for editing.</param>
		/// <param name="textBoxValidationRule">The validation rule for the text box that is used for editing.</param>
		public TextEditingAdorner(UIElement adornedElement, string initialText, Style textBoxStyle, ValidationRule textBoxValidationRule)
			: base(adornedElement)
		{
			_visualChildren = new VisualCollection(this);

			EditedText = initialText; // initialize the EditedText property with the actual text , so when our TextBox bounds to it, it is also initialized with the actual text.

			// Build the text box
			_textBox = new TextBox();

			if (textBoxStyle != null)
			{
				_textBox.Style = textBoxStyle; // Apply a style to the TextBox, if a style was provided
			}
			else
			{
				_textBox.Padding = new Thickness(0, 0, _extraWidth, 0);
			}

			// Trick: we bind the text of our TextBox to our own property 'EditedText'. Even if we not really need this property, the binding provides us with the possibility of validation
			// and to change the style to an ErrorTemplate if validation fails.
			Binding binding = new Binding("EditedText");
			binding.Mode = BindingMode.TwoWay;
			binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
			binding.Source = this;
			if (null != textBoxValidationRule)
			{
				binding.ValidationRules.Add(textBoxValidationRule); // Add a validation rule if it was provided
			}
			_textBox.SetBinding(TextBox.TextProperty, binding);

			_visualChildren.Add(_textBox);

			//Update TextBox's focus status when layout finishs.
			_textBox.LayoutUpdated += new EventHandler(EhTextBox_LayoutUpdated);

			_textBox.KeyDown += new KeyEventHandler(EhTextBoxKeyDown);
			_textBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(EhTextBoxLostKeyboardFocus);
			_textBox.LostFocus += EhTextBoxLostFocus;
		}
Exemple #5
0
 /// <summary>
 /// ValidationError ctor
 /// <param name="ruleInError">rule that detected validation error</param>
 /// <param name="bindingInError">BindingExpression for which validation failed</param>
 /// </summary>
 public ValidationError(ValidationRule ruleInError, object bindingInError) : this(ruleInError, bindingInError, null, null)
 {
 }
 public ValidationError(ValidationRule ruleInError, Object bindingInError)
 {
 }
 public ValidationError(ValidationRule ruleInError, Object bindingInError, Object errorContent, Exception exception)
 {
 }
Exemple #8
0
 /// <summary>
 /// ValidationError ctor
 /// <param name="ruleInError">rule that detected validation error</param>
 /// <param name="bindingInError">BindingExpression for which validation failed</param>
 /// </summary>
 public ValidationError(ValidationRule ruleInError, object bindingInError) : this(ruleInError, bindingInError, null, null)
 {
 }
 public ValidationError(ValidationRule ruleInError, Object bindingInError)
 {
 }
 public ValidationError(ValidationRule ruleInError, Object bindingInError, Object errorContent, Exception exception)
 {
 }
		public OptionalValidationRule(ValidationRule rule)
		{
			this.rule = rule;
		}
        ValidationError RunValidationRule(ValidationRule validationRule, object value, CultureInfo culture)
        {
            ValidationError error;

            ValidationResult validationResult = validationRule.Validate(value, culture, this);

            if (validationResult.IsValid)
            {
                error = null;
            }
            else
            {
                if (TraceData.IsExtendedTraceEnabled(this, TraceDataLevel.Update))
                {
                    TraceData.Trace(TraceEventType.Warning,
                                        TraceData.ValidationRuleFailed(
                                            TraceData.Identify(this),
                                            TraceData.Identify(validationRule)));
                }

                error = new ValidationError(validationRule, this, validationResult.ErrorContent, null);
            }

            return error;
        }
 public PassthroughCellValidationRule( ValidationRule validationRule )
 {
   m_validationRule = validationRule;
 }
Exemple #14
0
    internal static bool GetIsRuleInErrorRestrictive( ValidationRule ruleInError )
    {
      if( ruleInError == null )
        return false;

      return !( ruleInError is DataErrorValidationRule );
    }
 public CellContentBindingValidationRule( ValidationRule validationRule )
   : base( validationRule )
 {
 }