WEB开发网
开发学院图形图像Flash Silverlight 3 Beta 新特性解析(5) - Data篇 阅读

Silverlight 3 Beta 新特性解析(5) - Data篇

 2009-03-26 11:59:31 来源:WEB开发网   
核心提示: 将ProductGrid当前选中的Item绑定给DataForm来显示,其中AutoGenerateFields="False"代表将自定义显示和编辑的FieldsCommitButtonContent和CancelButtonContent分别用来设置保存按钮和取消按

将ProductGrid当前选中的Item绑定给DataForm来显示,其中AutoGenerateFields="False"代表将自定义显示和编辑的Fields

CommitButtonContent和CancelButtonContent分别用来设置保存按钮和取消按钮的显示内容,而第2~8行就是自定义的显示和编辑的Fields

ItemEditEnded用来表示你按下保存按钮或者取消按钮时触发的事件,如下

  1: private void ProductForm_ItemEditEnded(object sender, DataFormItemEditEndedEventArgs e)

  2: {

  3:   if (e.EditAction == DataFormEditAction.Commit)

  4:   {

  5:     ProductDataSource.SubmitChanges();

  6:   }

  7: }

表示只有按下保存按钮才保存信息内容

验证(Validation):

在.Net RIA Service介绍和实战这一部分我曾经说过.Net RIA Service是在metadata类设置验证要求的

这是ProductService.metadata.cs这个类的原始设置

  1: internal sealed class ProductMetadata

  2: {

  3:   private ProductMetadata()

  4:   {

  5:   }

  6:  

  7:   public int ProductID;

  8:  

  9:   public string Name;

 10:  

 11:   public string ProductNumber;

 12:  

 13:   public bool MakeFlag;

 14:  

 15:   public bool FinishedGoodsFlag;

 16:  

 17:   public string Color;

 18:  

 19:   public short SafetyStockLevel;

 20:  

 21:   public short ReorderPoint;

 22:  

 23:   public Decimal StandardCost;

 24:  

 25:   public Decimal ListPrice;

 26:  

 27:   public string Size;

 28:  

 29:   public string SizeUnitMeasureCode;

 30:  

 31:   public string WeightUnitMeasureCode;

 32:  

 33:   public Nullable<Decimal> Weight;

 34:  

 35:   public int DaysToManufacture;

 36:  

 37:   public string ProductLine;

 38:  

 39:   public string Class;

 40:  

 41:   public string Style;

 42:  

 43:   public Nullable<int> ProductSubcategoryID;

 44:  

 45:   public Nullable<int> ProductModelID;

 46:  

 47:   public DateTime SellStartDate;

 48:  

 49:   public Nullable<DateTime> SellEndDate;

 50:  

 51:   public Nullable<DateTime> DiscontinuedDate;

 52:  

 53:   public Guid rowguid;

 54:  

 55:   public DateTime ModifiedDate;

 56:  

 57:   public EntityState EntityState;

 58: }

上一页  4 5 6 7 8 9 10  下一页

Tags:Silverlight 特性

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接