public override void Cleanup() { if (selectedStyle != null) { selectedStyle.PropertyChanged -= SelectedStyle_PropertyChanged; } selectedStyle = null; parent.PropertyChanged -= Parent_PropertyChanged; parent = null; base.Cleanup(); }
public SelectedStyleViewModel(StyleViewModel parent) { this.parent = parent; this.selectedStyle = parent.SelectedStyle; parent.PropertyChanged += Parent_PropertyChanged; if (selectedStyle != null) { selectedStyle.PropertyChanged += SelectedStyle_PropertyChanged; this.selectedIndex = parent.Styles.IndexOf(selectedStyle); } this.Delete = new RelayCommand(() => this.parent.Delete(this.selectedStyle), () => this.selectedStyle != null); this.Rename = new RelayCommand(rename, () => this.newName != null); }