需要:需要将数据绑定到WPF控件,以便用户更新数据库。
方法:我正在尝试实现类似于this的解决方案但是遇到了问题,因为我将使用DataSet而不是LINQ to SQL Class(为我的数据命中Oracle数据库)。如果这是一种正确的方法,我该怎么做?
我也在考虑而不是将数据添加到集合中,为什么我不直接绑定到数据集并使用数据集的事件(RowChanged)来更新我的数据库。我是WPF的新手,所以我确信有充分的理由。
我的表格:
Public Class frmTest
Private Shared _adjData As New BudgetTrackDAL.dsBudgetChangeIndirect()
Private _adjCollection As ObservableAdjustments
Private Sub frmTest_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
_adjData = DB.GetBudgetAdjustments("501", "", "2010")
' Pass populated dataset
_adjCollection = New ObservableAdjustments(_adjData)
End Sub
我的收藏班:
Public Class ObservableAdjustments
Inherits ObservableCollection(Of BudgetTrackDAL.dsBudgetChangeIndirect)
Public Sub New(ByVal myDataSet As dsBudgetChangeIndirect)
'***********************
' This is where I want to load the collection from my dataset
For Each row In myDataSet
Add(row)
Next
'***********************
End Sub
结束班