void UpdatePosition()
        {
            TextView textView = this.TextArea.TextView;
            // PointToScreen returns device dependent units (physical pixels)
            Point location = textView.PointToScreen(visualLocation - textView.ScrollOffset);
            Point locationTop = textView.PointToScreen(visualLocationTop - textView.ScrollOffset);

            // Let's use device dependent units for everything
            Size completionWindowSize = new Size(this.ActualWidth, this.ActualHeight).TransformToDevice(textView);
            Rect bounds = new Rect(location, completionWindowSize);
            Rect workingScreen = System.Windows.Forms.Screen.GetWorkingArea(location.ToSystemDrawing()).ToWpf();
            if (!workingScreen.Contains(bounds)) {
                if (bounds.Left < workingScreen.Left) {
                    bounds.X = workingScreen.Left;
                } else if (bounds.Right > workingScreen.Right) {
                    bounds.X = workingScreen.Right - bounds.Width;
                }
                if (bounds.Bottom > workingScreen.Bottom) {
                    bounds.Y = locationTop.Y - bounds.Height;
                }
                if (bounds.Y < workingScreen.Top) {
                    bounds.Y = workingScreen.Top;
                }
            }
            // Convert the window bounds to device independent units
            bounds = bounds.TransformFromDevice(textView);
            this.Left = bounds.X;
            this.Top = bounds.Y;
        }