我有一個簡單的類與一個字符串屬性和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