Windows 8 Metro: Validation Implementation

I just searched the Internet for about 2 hours and found nothing.

Given the following scenario:

public class Person
{
    [Required]
    public string Name { get; set; }
}

XAML:

<TextBox Text="{Binding Name, Mode=TwoWay}" />

How could you automatically get validation feedback in the user interface, like in MVC3?

(Oh, and I really don't care if I can use integrated DataAnnotations, such as [Required] or not)

Any help is much appreciated!

+5
source share
3 answers

I added something to the WinRT XAML Toolkit . It is called TextBoxValidationExtensions and allows you to define validation as follows:

<TextBox
    Width="400"
    HorizontalAlignment="Left"
    xyzc:TextBoxValidationExtensions.Format="NonEmptyNumeric"
    xyzc:TextBoxValidationExtensions.InvalidBrush="Red"
    xyzc:TextBoxValidationExtensions.ValidBrush="Green" />

Formats are currently defined as:

[Flags]
public enum ValidTextBoxFormats
{
    Any = 0,
    NonEmpty = 1,
    Numeric = 2,
    NonEmptyNumeric = 3
}

, . CodePlex - , ..

+13

XAML, , textbox pointerexited , .

0

It seems, based on the support provided within the framework, that your unusual idea of ​​"checking" the text box is so rare and unusual that it does not need to be considered at all. We all know that if what you wanted to do would be general or useful, in such a well-designed and comprehensive structure, there would be some attention to such a function.

-1
source

All Articles