Silverlight 4 将新项目添加到 DomainDataSource
我有一个简单的数据网格,列出地址和一个子窗口,用户可以在其中编辑/添加新地址。在带有数据网格的主窗体上,我有一个“插入新地址”按钮,该按钮应该使用空的地址对象加载子窗口。但是它不会让我添加记录。我做错了什么吗?我当前的代码如下:
Dim address As New Address
Dim frmAddressObj As New frmAddress
If frmAddressObj.AddressDomainDataSource.DataView.CanAdd = False Then
frmAddressObj.AddressDomainDataSource.Load()
End If
frmAddressObj.AddressDomainDataSource.DataView.Add(address)
Address 是地址对象。 frmAddress 是子窗口窗体。 AddressDomainDataSource 与我在数据网格中使用的数据源与在子级中使用的数据源相同。 CanAdd 总是错误的,我被告知在添加之前尝试加载,但这似乎没有帮助。当它到达 Add 方法时,它返回此 ICollectionView 不支持“Add”的异常。任何帮助将不胜感激。谢谢
I have a simple datagrid listing addresses and a child window where the user can edit/add new. On the main form with the datagrid i have a button to "Insert New Address" which should load the child window with an empty Address object. However it will not let me add a record. Am i doing something wrong? my current code is as follows:
Dim address As New Address
Dim frmAddressObj As New frmAddress
If frmAddressObj.AddressDomainDataSource.DataView.CanAdd = False Then
frmAddressObj.AddressDomainDataSource.Load()
End If
frmAddressObj.AddressDomainDataSource.DataView.Add(address)
Address is the address object. frmAddress is the child window form. AddressDomainDataSource is the same datasource i use in the datagrid as i use in the child. CanAdd is always false and i got told to try loading before adding but this does not appear to have helped. When it reaches the Add method it returns an Exception of 'Add' is not supported by this ICollectionView. Any help would be appreciated. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(3)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
DataView 字段应被视为只读集合。 DomainDataSource 与 DataGrid 的最简单的一般用法如下:
它与插入类似,您只需使用
而不是
,而对于更新您只需调用
The DataView field should be thought of as a read-only collection. The simplest general usage of the DomainDataSource with a DataGrid goes something like this:
It is similar for insert, you just use
instead of
And for updates you simply call