Version

ValueConstraint Class

Contains various constraints that can be applied to a data value.
Syntax
'Declaration
 
Public Class ValueConstraint 
   Inherits System.Windows.DependencyObject
public class ValueConstraint : System.Windows.DependencyObject 
Remarks

ValueConstraint object contains various properties that you can set to create constraints for data values. The ValueConstraint will check to see if a data value matches all the constraints.

ValueEditor class exposes ValueEditor.ValueConstraint property that is of this object type. ValueEditor's ValueConstraint property can be used to constraint what values the user can input in the editors. See ValueEditor.ValueConstraint for more information.

You can use the ValueConstraint directly to validate a value by calling its Validate(Object,Type) or one of the other overloads.

Example
The following code snippet sets the ValueConstraint on a text editor. It sets the MinLength and MaxLength properties of the value constraint. This will ensure that the length of what user enters into the editor is between 2 and 4 characters. If the value entered does not satisfy all the constraints of the value constraint object then the editor will display an error message when the user attempts to leave the editor. The action taken by the editor can be controlled using the InvalidValueBehavior property of the editor.

<!--This editor will make sure that the text entered is between 2 and 4 characters long-->
<igEditors:XamTextEditor x:Name="textEditor3" InvalidValueBehavior="DisplayErrorMessage" >
    
<igEditors:XamTextEditor.ValueConstraint>
        
<igEditors:ValueConstraint MinLength="2" MaxLength="4" />
    
</igEditors:XamTextEditor.ValueConstraint>
</igEditors:XamTextEditor>
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also