从其他形式更新Xamdatagrid来源的最佳方法是什么?
我的MainWindow中有一个Xamdatagrid
,它具有public共享列表(Artikelstammdaten的公共共享列表)
作为dataSource
。打开其他表格后,我想在单击按钮时向Xamdatagrid
添加更多数据。我认为最简单的方法只是更新dataSource
,但我会遇到一个错误:
对未发布成员的引用需要对象参考。
这就是我尝试的:
Private Sub Add_Click(sender As Object, e As RoutedEventArgs)
Dim update = MainWindow.listArtikelstammdaten.Concat(CType(Import.ComparedAccessData, IEnumerable(Of Artikelstammdaten)))
dgArticleMasterData.DataSource = update
Me.Close()
End Sub
I have a XamDataGrid
in my MainWindow which has a Public Shared List(Of Artikelstammdaten)
as DataSource
. After opening a few other forms I want to add more data to the XamDataGrid
with a button click. I thought the easiest way would be just to update the DataSource
, but I get an Error:
The reference to an unreleased member requires an object reference.
This is what I have tried:
Private Sub Add_Click(sender As Object, e As RoutedEventArgs)
Dim update = MainWindow.listArtikelstammdaten.Concat(CType(Import.ComparedAccessData, IEnumerable(Of Artikelstammdaten)))
dgArticleMasterData.DataSource = update
Me.Close()
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果
dgarticlemasterdata
在mainWindow
类中定义,则需要获取对mainwindow
实例的引用才能访问它。您应该能够在
application.current.windows
集合中找到它:If
dgArticleMasterData
is defined in theMainWindow
class, you need to get a reference to theMainWindow
instance to be able to access it.You should be able to find it in the
Application.Current.Windows
collection: