Well, I have the following class definitions:
private ObservableCollection<Node> _Nodes;
public ObservableCollection<Node> Nodes
{
get
{
return _Nodes;
}
set
{
_Nodes = value;
OnPropertyChanged("Nodes");
}
}
Node class:
[Serializable]
public class Node : INotifyPropertyChanged
{
private string _Name;
[XmlAttribute("Name")]
public string Name
{
get
{
return _Name;
}
set
{
_Name = value;
OnPropertyChanged("Name");
}
}
private bool _IsChecked;
[XmlIgnore()]
public bool IsChecked
{
get
{
return _IsChecked;
}
set
{
_IsChecked = value;
OnPropertyChanged("IsChecked");
}
}
and when in the ViewModel I modify one element:
try
{
foreach (var node in AllNodes)
{
if (node.Children.Contains(s))
{
for (int i = 0; i < node.Children.Count; i++)
{
if (node.Children[i] == s)
{
node.Children[i] = null;
}
}
}
}
}
catch (NullReferenceException)
{
}
UI happens to do nothing. But loading the file again solves it 🙂
AllNodes is an ObservablCollection of Node
Is there a way to do that?
INorifyPropertyChanged has NOTHING to do with hat – you do not change a property, you relpace it.
So, the proper eveng in the ObservableCollection has to be observed. May I suggest you either have no observable colelction, or list binding is not properly set up. Your property change has NOTHING to do, as no property on an element is changed.
Somehow your vies is not getting the chang events that the Nodes collection is throwing. Bad binding.