0
我有一个公共属性StaticFailingPinListItem作为新的ObservableCollection(Of MyClass)在我的主用户控件UserControl1中。WPF将列表框绑定到ObservableCollection(Of MyClass)
Public Class UserControl1
Public Property StaticFailingPinListItem As New ObservableCollection(Of MyClass)
MyClass有两个属性 - PinName & ImageLocation。
Public Class MyClass
Implements INotifyPropertyChanged
Public Property PinName
Public Property ImageLocation
如果我在运行时手动添加项目到集合,我将能够在我的列表框中查看PinName属性。但是,如果我稍后添加项目(例如:在单击按钮之后)它不起作用。
这是我的XAML:
ItemsSource="{Binding ElementName =data2, Path=StaticFailingPinListItem}" DisplayMemberPath="PinName"
所以,问题是我怎么做一个代码隐藏数据绑定我的列表框填充了采集后?