我在TextBoxValidationExtensions,并允许你界定这种确认:
<TextBox
Width="400"
HorizontalAlignment="Left"
xyzc:TextBoxValidationExtensions.Format="NonEmptyNumeric"
xyzc:TextBoxValidationExtensions.InvalidBrush="Red"
xyzc:TextBoxValidationExtensions.ValidBrush="Green" />
表格目前的定义是:
[Flags]
public enum ValidTextBoxFormats
{
Any = 0,
NonEmpty = 1,
Numeric = 2,
NonEmptyNumeric = 3
}
The entire code is a bit too long to share here. You can take out the code from CodePlex and modify to your liking - add new validation rules, modify default brushes etc.