Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
1.22/5 (2 votes)
I'm developing UWP App as I'm new to this platform I'm totly un aware how to validate XAML controls in UWP App.

What I have tried:

I'm developing UWP App as I'm new to this platform I'm totly un aware how to validate XAML controls in UWP App.
Posted
Updated 21-Jun-16 9:30am

1 solution

What do you mean by validating the controls? The data of the controls is validated, instead of the XAML controls. You can do so, such as,
XML
<textbox name="username" />

Suppose you have to "validate" that the user must enter the username to be of length 5-25. You can validate the input using the C# code (or VB.NET if you are using that langauge),
C#
string inputData = username.Text; // Get the text

// Validate
if(inputData.Length < 5 || inputData.Length > 25) {
   // Notify the user about the error
}

Similarly, you can perform other checks on the controls that you are using, you can use their property values and then check them against the values that you want.

Jerry Nixon has written just a post about it, Jerry Nixon on Windows: Let&#8217;s Code! Handling validation in your Windows Store app (WinRT-XAML).[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900