我是wpf的新手,所以请耐心等待我
我为了管理“个人资料”记录而建立了一个窗口
导航和更新正常工作
我似乎也无法插入工作
这是非常简单的代码
Imports System.Collections.ObjectModel
Public Class Window1
Dim WindowEntities As New DataEntities
Dim WindowList As ObservableCollection(Of Profile)
Function ProfilesViewSource() As CollectionViewSource
Return CType(FindResource("ProfilesViewSource"), CollectionViewSource)
End Function
Function DefaultView() As CollectionView
Return CollectionViewSource.GetDefaultView(ProfilesViewSource.View)
End Function
Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs) Handles MyBase.Loaded
WindowList = New ObservableCollection(Of Profile)(From x In WindowEntities.Profiles Order By x.ProfileName)
ProfilesViewSource.Source = WindowList
End Sub
Private Sub btnSave_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) Handles btnSave.Click
WindowEntities.SaveChanges()
End Sub
Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) Handles btnAdd.Click
WindowList.Add(New Profile)
DefaultView.MoveCurrentToLast()
End Sub
Private Sub btnNext_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) Handles btnNext.Click
DefaultView.MoveCurrentToNext()
End Sub
End Class
当我按下添加时,我得到一个新的空记录,当我填写它时,我看到该集合看到它,因为有一个显示配置文件的通知列表框,它被列在那里,所以它实际附加到列表,但savechanges命令不会将其插入db
插入时可能会出现一些验证错误,但之后我会得到一些指示,对吗?现在它只是默默地失败了。好像我从不依赖于提交更改
非常感谢你的帮助伙伴