Silverlight Validation related

Source: Internet
Author: User

There is validation in ASP. NET MVC, of course, there are validation rules in Silverlight, but this is a matter of MVVM (actually the physical layer, the composition of the page these things, no use Ah, sorrow!) Even this concept is not understood).

For the use of the more authentic usage of MVVM validation, refer to: http://blog.csdn.net/junny12345/article/details/6185134

Not to mention the other, the thing is a step-by-step learning and accumulation.

First, it is necessary to verify that some entities are bound dynamically, but not binding, is it possible? I have not tried, imagine we can do this:

public class Mainpage:usercontrol

{

[Required]//Is it possible?

public int zip{get;set;}

}

Of course the entity is available:

public class User

{

private string name;

public int age{get;set;}

public string name{

Get{return name;}

set{

if (string. IsNullOrEmpty (value))

{

throw new Validationexception ("name is required.");

}

Name=value;

}

}

}

public class Mainpage:usercontrol

{

Public MainPage ()

{

InitializeComponent ();

This. Datacontext=new User ();

}

}

MainPage.xaml

<Grid>

<textblock x:name= "Tbname" text= "Name" ></TextBlock>

<textbox x:name= "Txtname" text= "{Binding name,mode=twoway,validatesonexceptions=true,notifyonvalidationerror= True} "></TextBox>

</Grid>

Reference: Http://www.codeproject.com/Articles/86955/Silverlight-Data-Validation-Tip-of-the-Day-Part

Silverlight Validation related

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.