public void SetPosition(int line, int column) { //CCSProfix = String.Empty; CodeTextBox.SetPosition(line, column); ScrollViewer sv = CodeTextBox.ScrollViewer; if (sv == null) { return; } double y = line * 19 - 25 - sv.ViewportHeight / 2; y = Math.Max(0, y); sv.ScrollToVerticalOffset(y); double x = column * 16 - sv.ViewportWidth / 2; x = Math.Max(0, x); sv.ScrollToHorizontalOffset(x); }