protected virtual void OKButtonClick(object sender, RoutedEventArgs e) { if (optionBindings != null) { foreach (OptionBinding binding in optionBindings) { binding.Save(); } } var typeResolveContext = refactoringContext.GetTypeResolveContext(); if (typeResolveContext == null) { return; } var current = typeResolveContext.CurrentTypeDefinition; using (editor.Document.OpenUndoGroup()) { // GenerateCode could modify the document. // So read anchor.Offset after code generation. GenerateCode(current); } Deactivate(); }