2010-07-25 42 views
1

一個DataGrid相同的頁面添加新行以在Silverlight WCF RIA服務

Control layout 
DataGrid 
Detail View [Add New Row (button)] 

如果我想從一個按鈕添加一個新行上使用Silverlight WCF RIA服務... DataGrid和詳細視圖的一些指導然後在datagrid中選擇新的行,我該怎麼做?

我曾嘗試:

DetailViewTest.Web.Services.Mode1DomainContext ctx = 
     (Mode1DomainContext)wordDomainDataSource.DomainContext; 

Word word = new Word() 
{ 
    Word1 = this.word1TextBox.Text, 
    DateAdded = DateTime.Now 
}; 
ctx.Words.Add(word); 
ctx.SubmitChanges(); 

這增加了字到該數據庫但不能即使對數據的數據源是wordDomainDataSource DataGrid中。如果我重新啓動應用程序,它會顯示在數據網格中。一些幫助,這將是偉大的!

(使用Silverlight 4的業務應用爲出發項目)

+0

祕密是 Word文字=新的Word() { 字1 = this.word1TextBox.Text, DateAdded = DateTime.Now }; wordDomainDataSource.DataView.Add(word); wordDomainDataSource.DataView.Add(word); – coder100 2010-07-25 04:33:45

回答

0

如果您使用的MVVM/INotifyPropertyChanged的模式,你可能需要火上的ItemSource的OnPropertyChanged事件。