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