Josh Smith demonstrates on The Code Project how regular expressions can be used to validate user input in a Windows Presentation Foundation (WPF) application.
The technique presented provide two ways for a developer to validate the text of a TextBox via regular expressions:
... explicitly adding a ValidationRule-derived object to the ValidationRules of a Binding, or simply using attached properties of a static service provider class.
If you need to specify a single RegexOptions value for the RegexValidationRule, you can use the RegexOptions property of that class in XAML, he writes.
When creating regular expressions in a XAML file, Smith cautions that XAML requires that certain characters must be escaped. These ‘certain characters’ include such as the ampersand and apostrophe.
More XAML info
XAML preps for application development
September 07, 2006 - Microsoft's Extensible Application Markup Language is poised to make it easier for developers and designers to collaborate.
Cider catching up with WPF design needs
September 06, 2006 - The code-name Cider WPF visual designer is becoming increasingly important as people begin to work on Windows Presentation Foundation projects.
WPF: Another darned revolution
September 05, 2006 - In the hopes that some of the cool kids on the leading edge might actually care about what we dinosaurs think, here's my collected list of reasons for ignoring WPF at the moment.
Smalltalk meets Vista and .NET
July 21, 2006 - A developer's goal is to influence people ready to consider Smalltalk as a potential option to Microsoft's XAML -and-C#-or-VB.NET approach to building rich Web interfaces using WPF.