private void EditButton_Click(object sender, RoutedEventArgs e) { var result = TextEditorWindow.Show(ContentTextBox.Text); if (result.Ok) { ContentTextBox.Text = result.Data; } }
public static TextEditorWindowResult Show(string with) { var window = new TextEditorWindow(); window.ContentTB.AppendText(with); if (window.ShowDialog().Value) { return new TextEditorWindowResult { Ok = true, Data = new TextRange(window.ContentTB.Document.ContentStart, window.ContentTB.Document.ContentEnd).Text } } ; else { return new TextEditorWindowResult { Ok = false } }; }