Windows 8 Metro: Implementing Validation

前端 未结 3 677
别那么骄傲
别那么骄傲 2021-01-18 18:10

I just googled for about 2 hours and didn\'t find anything.

Given the following scenario:

public class Person
{
    [Required]
    public string Name         


        
3条回答
  •  孤城傲影
    2021-01-18 18:41

    I added something to the WinRT XAML Toolkit. It's called TextBoxValidationExtensions and allows you to define the validation like this:

    
    

    The formats are currently defined as:

    [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.

提交回复
热议问题