我有一个简单的类与一个字符串属性和List属性,我有INofityPropertyChanged事件实现,但当我做一个.Add添加到字符串列表这个事件没有命中,所以我的转换器显示在ListView没有被击中。我猜属性改变没有命中一个添加到列表....我怎么能实现这个方式来获得该属性更改事件命中?List <string> INotifyPropertyChanged事件
我是否需要使用其他类型的集合?
感谢您的帮助!
namespace SVNQuickOpen.Configuration
{
public class DatabaseRecord : INotifyPropertyChanged
{
public DatabaseRecord()
{
IncludeFolders = new List<string>();
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
protected void Notify(string propName)
{
if (this.PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propName));
}
}
#endregion
private string _name;
public string Name
{
get { return _name; }
set
{
this._name = value;
Notify("Name");
}
}
private List<string> _includeFolders;
public List<string> IncludeFolders
{
get { return _includeFolders; }
set
{
this._includeFolders = value;
Notify("IncludeFolders");
}
}
}
}
这是钱!谢谢! – theDoke
**为什么**应该使用'ObservableCollection'? – C4u
@ C4u它可以用于WPF中的数据绑定(MVVM模式) – bniwredyc