public void AddNew(Step s) { StepView newKeyHolder = new StepView(s); newKeyHolder.PropertyChanged += new PropertyChangedEventHandler(KeyHolder_PropertyChanged); this.allKeys.Add(newKeyHolder); }
public void ClearSubKeys(StepView parentKeyHolder) { int indexToRemove = this.allKeys.IndexOf(parentKeyHolder) + 1; while ((indexToRemove < this.allKeys.Count) && (this.allKeys[indexToRemove].Level > parentKeyHolder.Level)) { this.allKeys.RemoveAt(indexToRemove); this.DataItemsCount--; } }
void KeyHolder_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "IsExpanded") { StepView keyHolder = (StepView)sender; if (keyHolder.IsExpanded) { this.PopulateSubKeys(keyHolder); } else { this.ClearSubKeys(keyHolder); } } }
public void PopulateSubKeys(StepView parent) { int indexParentKey = this.allKeys.IndexOf(parent); if (indexParentKey == this.allKeys.Count - 1 || this.allKeys[indexParentKey + 1].Level <= parent.Level) { for (int i = 0; i < parent.Key.Variants.Count; i++) { StepView childKeyHolder = new StepView(parent.Key.Variants[i]); childKeyHolder.PropertyChanged += KeyHolder_PropertyChanged; allKeys.Insert(indexParentKey + i + 1, childKeyHolder); this.DataItemsCount++; } } }