protected override async Task<string> ReadTextCoreAsync(int maxChars)
        {
            AssertIsForeground();

            var inputTextBox = new TextBox
            {
                FontFamily = normalFontFamily,
                FontSize = this.FontSize,
                Padding = new Thickness(0.0),
                Margin = new Thickness(0.0),
                BorderBrush = Brushes.Transparent,
                BorderThickness = new Thickness(0.0),
                Background = Brushes.WhiteSmoke,
                MaxLength = maxChars
            };

            var scrollContext = this.scrollViewer.FindFirstVisualChild<ScrollContentPresenter>();
            var lastCharacterRect = this.document.ContentEnd.GetCharacterRect(LogicalDirection.Forward);
            var minWidth = scrollContext.ActualHeight - this.document.PagePadding.Right - lastCharacterRect.Right;
            inputTextBox.MinWidth = Math.Max(minWidth, 0);

            var container = new InlineUIContainer(inputTextBox, this.document.ContentEnd)
            {
                BaselineAlignment = BaselineAlignment.TextBottom
            };

            this.paragraph.Inlines.Add(container);

            if (!inputTextBox.Focus())
            {
                inputTextBox.PostAction(() => inputTextBox.Focus());
            }

            string text = null;
            while (text == null)
            {
                var args = await inputTextBox.KeyUpAsync();
                if (args.Key == Key.Return)
                {
                    text = inputTextBox.Text;
                }
            }

            this.paragraph.Inlines.Remove(container);
            PutText(text + "\r\n", forceFixedWidthFont: false);

            return text;
        }