private void Apply() { Marker.Unmark(); if (Document == null) { return; } if (mySelectedElement == null && myPath != null) { var path = HtmlPath.TryParse(myPath); if (path != null) { // Trigger SelectionChanged event SelectedElement = ( HtmlElementAdapter )Document.GetElementByPath(path); } } else if (mySelectedElement != null && myPath == null) { // do NOT set property - it will reset SelectedElement again (StackOverflowException) myPath = mySelectedElement.GetPath().ToString(); } if (mySelectedElement == null || mySelectedElement.TagName.Equals("INPUT", StringComparison.OrdinalIgnoreCase)) { return; } Marker.Mark(mySelectedElement); mySelectedElement.Element.ScrollIntoView(false); }