从SubSonic 2.2集合创建WPF ObservableCollection [英] Create A WPF ObservableCollection From A SubSonic 2.2 Collection
本文介绍了从SubSonic 2.2集合创建WPF ObservableCollection的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有SubSonic 2.2创建的DAL,如何将其创建的Collections转换为WPF使用的代码(prev.VB.NET)中的WPF ObservableCollections?
If I have a DAL created by SubSonic 2.2, how do I convert the Collections created by it to WPF ObservableCollections in code (pref.VB.NET) to be consumed by WPF?
推荐答案
您必须手动将其添加到DAL类中,但这并不难.在每个数据访问层类的顶部,添加"Implements INotifyPropertyChanged",然后在每个属性的"set"中添加代码,如下所示.
You would have to manually add this to your DAL classes, but it's not too hard. In the top of each data access layer class, add "Implements INotifyPropertyChanged" and then in each property, add the code in the "set" like you see below.
Private _Book As String
Public Property Book() As String
Get
Return _Book
End Get
Set(ByVal value As String)
If Not _Book = value Then
_Book = value
' Raise the property changed event.
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("Book"))
End If
End Set
End Property
Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
这篇关于从SubSonic 2.2集合创建WPF ObservableCollection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文