我想删除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));
}