public void RemoveChild(MapValueViewModel child) { var value = Value; if (!(value is Array)) { throw new Exception($"Cannot remove child from none array item {Key}"); } var array = (Array)value; array.Remove(child.Map); Value = array; }
public MapValueViewModel(string key, Map Map, MapValueViewModel parent) { _key = key; _map = Map; // Run validation var value = _map[_key]; ValidateValue(value); if (value is Array array) { array.CollectionChanged += Array_CollectionChanged; } _map.PropertyChanged += _Map_PropertyChanged; foreach (var innerValue in _map.Values) { if (innerValue is Map map) { map.PropertyChanged += _Map_PropertyChanged; } } }