Share via

Validator.TryValidateProperty Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Determines whether the specified property value is valid.

Namespace:  System.ComponentModel.DataAnnotations
Assembly:  System.ComponentModel.DataAnnotations (in System.ComponentModel.DataAnnotations.dll)


Public Shared Function TryValidateProperty ( _
    value As Object, _
    validationContext As ValidationContext, _
    validationResults As ICollection(Of ValidationResult) _
) As Boolean
public static bool TryValidateProperty(
    Object value,
    ValidationContext validationContext,
    ICollection<ValidationResult> validationResults


Return Value

Type: System.Boolean
true if the property is valid; otherwise, false.


Exception Condition

MemberName of validationContext is not a valid property.


The TryValidateProperty method tests each ValidationAttribute attribute associated with the property that is identified by the validationContext parameter.

If validationResults is nulla null reference (Nothing in Visual Basic), the method stops at the first validation failure. If validationResults is not nulla null reference (Nothing in Visual Basic), the method evaluates all validation attributes and adds all of the failures to validationResults.

Version Information


Supported in: 5, 4, 3


For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.