private void LinkClicked(object sender, RoutedEventArgs e) { string selection; Editor.Document.Selection.GetText(TextGetOptions.None, out selection); var dialog = new LinkDialog(selection); var viewModel = dialog.DataContext as LinkViewModel; dialog.Added = () => TransformText(s => string.Format("[{0}]({1})", viewModel.DisplayText, viewModel.LinkAddress)); dialog.ShowAsync(); }