private void control_TextSelectionChanged(object source, NoteViewModel note) { _currentNoteControl = source as NoteControl; if (_currentNoteControl != null) { var selectionBrush = _currentNoteControl.txtNote.Selection.GetPropertyValue(TextElement.ForegroundProperty) as SolidColorBrush; if (selectionBrush != null) { btnColor.SelectedColor = selectionBrush.Color; } else { btnColor.SelectedColor = Color.FromArgb(0, 0, 0, 0); } } }
private void RedrawNotes(NoteViewModel selected = null) { notesPanel.Children.Clear(); foreach (NoteViewModel m in _model) { var control = new NoteControl(User, m) { IsReadOnly = IsReadOnly }; control.NoteDeleted += new NoteControl.NoteEventHandler(control_NoteDeleted); control.TextSelectionChanged += new NoteControl.NoteEventHandler(control_TextSelectionChanged); if (selected != null && selected == m) { control.IsExpanded = true; } notesPanel.Children.Add(control); } }