SkillAgentSearch skills...

Gu.Wpf.Validation

Attached properties for WPF TextBox

Install / Use

/learn @GuOrg/Gu.Wpf.Validation
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Gu.Wpf.Validation

A set of attached properties for TextBox.

Sample:

<TextBox validation:Input.Value="{Binding DoubleValue}"
         validation:Input.NumberStyles="AllowDecimalPoint,AllowLeadingSign,AllowLeadingWhite"
         validation:Input.Min="-10"
         validation:Input.Max="10"
         validation:Input.DecimalDigits="2"
         validation:Input.ValidationTrigger="PropertyChanged" />

<TextBox validation:Input.Value="{Binding StringValue}"
         validation:Input.Pattern="a\d+"
         validation:Input.IsRequired="True"
         validation:Input.ValidationTrigger="PropertyChanged" />

For more samples see demo project.

  • Creates a binding Text > validation:Input.Value internally. The binding has validationrules so it uses standard WPF validation. It picks up the type from the binding and selects default parsing/validation/formatting based on that.
  • No custom controls.
  • Higly configurable.
    • IValidator, plug in a validator of your own.
    • ITypeNumberStyles, plug in default numberstyles of choice.
    • ITypeRules, plug in default validationrules of choice.
    • ITypeStringConverters, plug in custom handling of to/from string.
    • All ^ can of course be bound per instance.
  • Validates as you type or on lost focus.

Related Skills

View on GitHub
GitHub Stars9
CategoryDevelopment
Updated1y ago
Forks1

Languages

C#

Security Score

70/100

Audited on Mar 27, 2025

No findings