void OnGotoDef(object sender, EventArgs e) { var dialog = new GoToDefinition() { ID = this.xmlText.SelectedText }; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Identifier id = Identifier.Get(dialog.ID); RuleElement elem; if (this.currentDocument.TryGetElement(id, out elem)) { SelectNode(elem); } else { elem = this.currentDocument.GetElementsByName(id).FirstOrDefault(); if (elem != null) { SelectNode(elem); } } } }