void HandleExclusive(object sender, EventArgs e) { NoteControl noteControl = sender as NoteControl; int row = Grid.GetRow(noteControl); for (int i = 0; i < Notes.Count; i++) { Notes[i].PropertyChanged -= NotePropertyChanged; Notes[i].IsUsed = i == row; Notes[i].PropertyChanged += NotePropertyChanged; } if (SomethingChanged != null) { SomethingChanged(this, new EventArgs()); } }
private void Init() { for (int i = 0; i < Notes.Count; i++) { Notes[i].PropertyChanged += NotePropertyChanged; NoteControl noteControl = new NoteControl(); noteControl.HandleExclusive += HandleExclusive; noteControl.DataContext = Notes[i]; Grid.SetRow(noteControl, i); RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) }); Children.Add(noteControl); } }