的ObservableCollection<>删除项目后列表不会更新

时间:2016-08-09 09:00:16

标签: c# wpf mvvm resharper observablecollection

我想删除TreeView中绑定了ObservableCollection<TreeNode> TreeViewNode,类型TreeNode的{​​{1}}项。但是,当我删除项TreeViewNodes.Remove(_item);时,列表不会更新。

我用:

public class TreeNode: TreeViewItem
{
    public string Type { get; set; }
    public string Name { get; set; }       
}

public event PropertyChangedEventHandler PropertyChanged;

[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
    PropertyChangedEventHandler handler = PropertyChanged;
    if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}

0 个答案:

没有答案