本文整理匯總了C#中System.Windows.Controls.TextBox.ClearValidationError方法的典型用法代碼示例。如果您正苦於以下問題:C# TextBox.ClearValidationError方法的具體用法?C# TextBox.ClearValidationError怎麽用?C# TextBox.ClearValidationError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Controls.TextBox
的用法示例。
在下文中一共展示了TextBox.ClearValidationError方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Reminder
public void Reminder()
{
var textBox = new TextBox();
var inputTypes = new InputTypeCollection { typeof(TextBox), typeof(Selector) };
textBox.SetForInputTypes(inputTypes);
Assert.AreEqual(false, Scope.GetHasErrors(textBox));
var errorNode = (ErrorNode)Scope.GetErrors(textBox);
Assert.AreEqual(textBox, errorNode.Source);
CollectionAssert.IsEmpty(errorNode.Children);
Assert.Fail("Implement");
// CollectionAssert.IsEmpty(errorNode.Errors);
textBox.SetValidationError();
Assert.AreEqual(true, Scope.GetHasErrors(textBox));
errorNode = (ErrorNode)Scope.GetErrors(textBox);
Assert.AreEqual(textBox, errorNode.Source);
CollectionAssert.IsEmpty(errorNode.Children);
// CollectionAssert.AreEqual(new[] {TestValidationError.GetFor(textBox)} ,errorNode.Errors);
textBox.ClearValidationError();
Assert.AreEqual(false, Scope.GetHasErrors(textBox));
errorNode = (ErrorNode)Scope.GetErrors(textBox);
Assert.AreEqual(textBox, errorNode.Source);
CollectionAssert.IsEmpty(errorNode.Children);
// CollectionAssert.IsEmpty(errorNode.Errors);
}
示例2: NodesForInputTypesTextBox
public void NodesForInputTypesTextBox()
{
var textBox = new System.Windows.Controls.TextBox();
var stackPanel = new StackPanel();
stackPanel.Children.Add(textBox);
var inputTypes = new InputTypeCollection { typeof(System.Windows.Controls.TextBox), typeof(Selector) };
Scope.SetForInputTypes(stackPanel, inputTypes);
Assert.AreEqual(false, Scope.GetHasError(stackPanel));
Assert.AreEqual(false, Scope.GetHasError(textBox));
Assert.AreSame(ErrorCollection.EmptyValidationErrors, Scope.GetErrors(stackPanel));
Assert.AreSame(ErrorCollection.EmptyValidationErrors, Scope.GetErrors(textBox));
Assert.AreEqual(ValidNode.Default, Scope.GetNode(stackPanel));
var errorNode = (InputNode)Scope.GetNode(textBox);
Assert.AreEqual(false, errorNode.HasError);
Assert.AreNotSame(ErrorCollection.EmptyValidationErrors, errorNode.Errors);
CollectionAssert.IsEmpty(errorNode.Errors);
CollectionAssert.IsEmpty(errorNode.Children);
var validationError = TestValidationError.GetFor(textBox, System.Windows.Controls.TextBox.TextProperty);
textBox.SetValidationError(validationError);
Assert.AreEqual(true, Scope.GetHasError(stackPanel));
Assert.AreEqual(true, Scope.GetHasError(textBox));
var expectedErrors = new[] { validationError };
CollectionAssert.AreEqual(expectedErrors, Scope.GetErrors(stackPanel));
CollectionAssert.AreEqual(expectedErrors, Scope.GetErrors(textBox));
var scopeNode = (ScopeNode)Scope.GetNode(stackPanel);
CollectionAssert.AreEqual(new[] { errorNode }, scopeNode.Children);
Assert.AreSame(errorNode, Scope.GetNode(textBox));
Assert.AreEqual(true, scopeNode.HasError);
Assert.AreEqual(true, errorNode.HasError);
CollectionAssert.AreEqual(expectedErrors, scopeNode.Errors);
CollectionAssert.AreEqual(expectedErrors, errorNode.Errors);
textBox.ClearValidationError(validationError);
Assert.AreEqual(false, Scope.GetHasError(stackPanel));
Assert.AreEqual(false, Scope.GetHasError(textBox));
Assert.AreSame(ErrorCollection.EmptyValidationErrors, Scope.GetErrors(stackPanel));
Assert.AreSame(ErrorCollection.EmptyValidationErrors, Scope.GetErrors(textBox));
Assert.AreEqual(ValidNode.Default, Scope.GetNode(stackPanel));
Assert.AreSame(errorNode, Scope.GetNode(textBox));
Assert.AreEqual(false, errorNode.HasError);
Assert.AreNotSame(ErrorCollection.EmptyValidationErrors, errorNode.Errors);
CollectionAssert.IsEmpty(errorNode.Errors);
CollectionAssert.IsEmpty(errorNode.Children);
}
示例3: UpdatesError
public void UpdatesError()
{
var textBox = new TextBox();
var inputTypes = new InputTypeCollection { typeof(TextBox), typeof(Selector) };
textBox.SetForInputTypes(inputTypes);
Assert.AreEqual(false, Scope.GetHasErrors(textBox));
var errorNode = (ErrorNode)Scope.GetErrors(textBox);
Assert.AreEqual(textBox, errorNode.Source);
CollectionAssert.IsEmpty(errorNode.Children);
textBox.SetValidationError();
Assert.AreEqual(true, Scope.GetHasErrors(textBox));
errorNode = (ErrorNode)Scope.GetErrors(textBox);
Assert.AreEqual(textBox, errorNode.Source);
CollectionAssert.IsEmpty(errorNode.Children);
textBox.ClearValidationError();
Assert.AreEqual(false, Scope.GetHasErrors(textBox));
errorNode = (ErrorNode)Scope.GetErrors(textBox);
Assert.AreEqual(textBox, errorNode.Source);
CollectionAssert.IsEmpty(errorNode.Children);
}
示例4: UpdatesError
public void UpdatesError()
{
var textBox = new TextBox();
var stackPanel = new StackPanel();
stackPanel.Children.Add(textBox);
var inputTypes = new InputTypeCollection { typeof(TextBox), typeof(Selector) };
stackPanel.SetForInputTypes(inputTypes);
Assert.AreEqual(false, Scope.GetHasErrors(stackPanel));
IErrorNode errorNode = (ScopeNode)Scope.GetErrors(stackPanel);
Assert.AreEqual(null, errorNode);
Assert.AreEqual(false, Scope.GetHasErrors(textBox));
errorNode = (ErrorNode)Scope.GetErrors(textBox);
Assert.AreEqual(textBox, errorNode.Source);
CollectionAssert.IsEmpty(errorNode.Children);
textBox.SetValidationError();
Assert.AreEqual(true, Scope.GetHasErrors(stackPanel));
errorNode = (ScopeNode)Scope.GetErrors(stackPanel);
Assert.AreEqual(stackPanel, errorNode.Source);
Assert.AreEqual(1, errorNode.Children.Count);
Assert.AreEqual(true, Scope.GetHasErrors(textBox));
errorNode = (ErrorNode)Scope.GetErrors(textBox);
Assert.AreEqual(textBox, errorNode.Source);
CollectionAssert.IsEmpty(errorNode.Children);
textBox.ClearValidationError();
Assert.AreEqual(false, Scope.GetHasErrors(stackPanel));
errorNode = (ScopeNode)Scope.GetErrors(stackPanel);
Assert.AreEqual(null, errorNode);
Assert.AreEqual(false, Scope.GetHasErrors(textBox));
errorNode = (ErrorNode)Scope.GetErrors(textBox);
Assert.AreEqual(textBox, errorNode.Source);
CollectionAssert.IsEmpty(errorNode.Children);
}
示例5: UpdatesAndNotifiesError
public void UpdatesAndNotifiesError()
{
var textBox = new System.Windows.Controls.TextBox();
var inputTypes = new InputTypeCollection { typeof(System.Windows.Controls.TextBox), typeof(Selector) };
Scope.SetForInputTypes(textBox, inputTypes);
Assert.AreEqual(false, Scope.GetHasError(textBox));
var errorNode = (InputNode)Scope.GetNode(textBox);
var errorArgs = errorNode.Errors.SubscribeObservableCollectionEvents();
var nodeArgs = errorNode.SubscribePropertyChangedEvents();
Assert.AreEqual(textBox, errorNode.Source);
CollectionAssert.IsEmpty(errorNode.Children);
CollectionAssert.IsEmpty(errorNode.Errors);
var validationError = TestValidationError.GetFor(textBox, System.Windows.Controls.TextBox.TextProperty);
textBox.SetValidationError(validationError);
Assert.AreEqual(true, Scope.GetHasError(textBox));
errorNode = (InputNode)Scope.GetNode(textBox);
Assert.AreEqual(textBox, errorNode.Source);
CollectionAssert.IsEmpty(errorNode.Children);
CollectionAssert.AreEqual(new[] { validationError }, errorNode.Errors);
var expectedErrorArgs = new List<EventArgs>
{
new PropertyChangedEventArgs("Count"),
new PropertyChangedEventArgs("Item[]"),
new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, validationError, 0)
};
CollectionAssert.AreEqual(expectedErrorArgs, errorArgs, ObservableCollectionArgsComparer.Default);
CollectionAssert.AreEqual(new[] { new PropertyChangedEventArgs(nameof(Node.HasError)) }, nodeArgs, PropertyChangedEventArgsComparer.Default);
textBox.ClearValidationError(validationError);
Assert.AreEqual(false, Scope.GetHasError(textBox));
Assert.AreSame(errorNode, Scope.GetNode(textBox));
Assert.AreEqual(textBox, errorNode.Source);
CollectionAssert.IsEmpty(errorNode.Children);
CollectionAssert.IsEmpty(errorNode.Errors);
expectedErrorArgs.Add(new PropertyChangedEventArgs("Count"));
expectedErrorArgs.Add(new PropertyChangedEventArgs("Item[]"));
expectedErrorArgs.Add(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, validationError, 0));
CollectionAssert.AreEqual(expectedErrorArgs, errorArgs, ObservableCollectionArgsComparer.Default);
CollectionAssert.AreEqual(new[] { new PropertyChangedEventArgs(nameof(Node.HasError)), new PropertyChangedEventArgs(nameof(Node.HasError)) }, nodeArgs, PropertyChangedEventArgsComparer.Default);
}
示例6: Notifies
public void Notifies()
{
var textBox = new System.Windows.Controls.TextBox();
var textBoxEvents = textBox.SubscribeScopeEvents();
Scope.SetForInputTypes(textBox, new InputTypeCollection { typeof(System.Windows.Controls.TextBox), typeof(Selector) });
var validationError = TestValidationError.GetFor(textBox, System.Windows.Controls.TextBox.TextProperty);
textBox.SetValidationError(validationError);
var expectedEvents = new List<ScopeValidationErrorEventArgs>
{
new ScopeValidationErrorEventArgs(validationError, ValidationErrorEventAction.Added)
};
CollectionAssert.AreEqual(expectedEvents, textBoxEvents, ScopeValidationErrorEventArgsComparer.Default);
textBox.ClearValidationError(validationError);
expectedEvents.Add(new ScopeValidationErrorEventArgs(validationError, ValidationErrorEventAction.Removed));
CollectionAssert.AreEqual(expectedEvents, textBoxEvents, ScopeValidationErrorEventArgsComparer.Default);
}
示例7: UpdatesErrors
public void UpdatesErrors()
{
var textBox = new System.Windows.Controls.TextBox();
var stackPanel = new StackPanel();
stackPanel.Children.Add(textBox);
var inputTypes = new InputTypeCollection { typeof(System.Windows.Controls.TextBox), typeof(Selector) };
Scope.SetForInputTypes(stackPanel, inputTypes);
Assert.AreEqual(false, Scope.GetHasError(stackPanel));
Assert.AreEqual(ValidNode.Default, Scope.GetNode(stackPanel));
Assert.AreEqual(false, Scope.GetHasError(textBox));
var inputNode = (InputNode)Scope.GetNode(textBox);
Assert.AreEqual(textBox, inputNode.Source);
CollectionAssert.IsEmpty(inputNode.Children);
CollectionAssert.IsEmpty(inputNode.Errors);
var validationError = TestValidationError.GetFor(textBox, System.Windows.Controls.TextBox.TextProperty);
textBox.SetValidationError(validationError);
Assert.AreEqual(true, Scope.GetHasError(stackPanel));
var scopeNode = (ScopeNode)Scope.GetNode(stackPanel);
Assert.AreEqual(stackPanel, scopeNode.Source);
Assert.AreEqual(1, scopeNode.Children.Count);
CollectionAssert.AreEqual(new[] { validationError }, scopeNode.Errors);
Assert.AreEqual(true, Scope.GetHasError(textBox));
Assert.AreSame(inputNode, Scope.GetNode(textBox));
Assert.AreEqual(textBox, inputNode.Source);
CollectionAssert.IsEmpty(inputNode.Children);
CollectionAssert.AreEqual(new[] { validationError }, inputNode.Errors);
textBox.ClearValidationError(validationError);
Assert.AreEqual(false, Scope.GetHasError(stackPanel));
Assert.AreEqual(ValidNode.Default, Scope.GetNode(stackPanel));
Assert.AreEqual(false, Scope.GetHasError(textBox));
Assert.AreSame(inputNode, Scope.GetNode(textBox));
Assert.AreEqual(textBox, inputNode.Source);
CollectionAssert.IsEmpty(inputNode.Children);
CollectionAssert.IsEmpty(inputNode.Errors);
}