Won't Fix
Last Updated: 24 Mar 2026 10:53 by ADMIN
Martin Ivanov
Created on: 24 Dec 2025 10:59
Category: RichTextBox
Type: Bug Report
1
RichTextBox: ArgumentException is thrown when using the Windows voice typing function (WinKey+H) to dictate text

ArgumentException occurs when using the voice typing feature of Windows (started with the Windows Key + H key combo) to convert speech to text in RadRichTextBox.

Exception stacktrace:

System.ArgumentException: 'Requested distance is outside the content of the associated document.'PresentationFramework.dll!System.Windows.Documents.TextPointer.TextPointer(System.Windows.Documents.TextContainer textContainer, int offset, System.Windows.Documents.LogicalDirection direction)
  PresentationFramework.dll!System.Windows.Documents.TextContainer.CreatePointerAtOffset(int offset, System.Windows.Documents.LogicalDirection direction) 
  PresentationFramework.dll!System.Windows.Documents.TextParentUndoUnit.Do() 
  PresentationFramework.dll!MS.Internal.Documents.UndoManager.Redo(int count) 
  PresentationFramework.dll!System.Windows.Documents.TextStore.RedoQuietly(int count)  PresentationFramework.dll!System.Windows.Documents.TextStore.SetFinalDocumentState(MS.Internal.Documents.UndoManager undoManager, System.Collections.Stack imeChangeStack, int appChangeCount, int imeSelectionAnchorOffset, int imeSelectionMovingOffset, int appSelectionAnchorOffset, int appSelectionMovingOffset)  PresentationFramework.dll!System.Windows.Documents.TextStore.HandleCompositionEvents(int previousUndoCount)  PresentationFramework.dll!System.Windows.Documents.TextStore.GrantLockWorker(MS.Win32.UnsafeNativeMethods.LockFlags flags)   PresentationFramework.dll!System.Windows.Documents.TextStore.RequestLock(MS.Win32.UnsafeNativeMethods.LockFlags flags, out int hrSession)

7 comments
ADMIN
Martin Ivanov
Posted on: 24 Mar 2026 10:53

Hello Valentin,

You are right, the described scenario might occur commonly, so I've logged an item to create an example at some point in time that shows a bit more refined approach, using RadRichTextBox and RadSpeechToTextButton. I also updated your Telerik points, as a small token of gratitude for bringing this to our attention.

As for the RadDocumentEditor, it doesn't replace the ActiveDocumentEditor. This is just a helper class that allows you to manipulate the document more easily.

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Valentin
Posted on: 23 Mar 2026 16:10

Thank you, Martin. I hacked something together using the sample code you provided. It seems to work for the most part but not always as expected.

For example, if the button is configured for continuous speech recognition and the user manipulates the editor content, the user edits are discarded. I understand why this happens - the button accummulates all the spoken text from the start of the speech recognition session and keeps inserting it at the original saved position.

I think however that this will be a fairly common scenario: the user will enter new lines or correct words that may have been misheard by the speech to text engine.

I guess we will need to prevent the user from changing the editor content while continuous speech recognition is happening or use the button without continuous recognition.

I was also wondering why the need for a separate DocumentEditor as opposed to using the RadRichTextBox's ActiveDocumentEditor?

ADMIN
Martin Ivanov
Posted on: 23 Mar 2026 15:03

Hello Valentin,

We don't have an example with RadRichTextBox, but here is what you can do. You can use the SpeechRecognized event of RadSpeechToTextButton to get the recognized text and then use the RadDocumentEditor to update the document. Based on the exact behavior you would expect the implementation may vary. Here is a basic approach that you can explore and modify if needed to match your requirement more closely.

private RadDocumentEditor documentEditor;
private PointF positionOrigin;        

public MainWindow()
{
    InitializeComponent();
    documentEditor = new RadDocumentEditor(this.rtb.Document);
}

private void RadSpeechToTextButton_SpeechRecognized(object sender, Telerik.SpeechRecognizer.SpeechRecognizerSpeechRecognizedEventArgs e)
{
    var start = new DocumentPosition(rtb.Document.CaretPosition);
    start.SetPosition(positionOrigin);
    var end = new DocumentPosition(rtb.Document.CaretPosition);
    rtb.Document.Selection.SetSelectionStart(start);
    rtb.Document.Selection.AddSelectionEnd(end);

    documentEditor.Delete(true);
    documentEditor.Insert(e.FullText);
}

private void sttb_StateChanged(object sender, EventArgs e)
{
    if (sttb.State == Telerik.SpeechRecognizer.SpeechRecognizerState.Listening)
    {
        positionOrigin = rtb.Document.CaretPosition.Location;
    }
}

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Valentin
Posted on: 19 Mar 2026 17:14

OK Dimitar, we are going to give the speech to text button a try. 

I looked at the documentation and example WPF app and they all appear geared toward entering text in watermark text boxes.

Does the button work with a RADRichTextBox and if so, do you have an example?

ADMIN
Dimitar
Posted on: 18 Mar 2026 09:18

Hello Valentin,

I have investigated this, and the issue is located in the .NET Framework. I have tested this with the latest Windows version (25H2), and there is no exception there. However, this is still not working there as expected. 

We have introduced a new SpeechToTextButton control that can be used for this. I would recommend using it instead since it works better than the default Windows recognition.

Please note that the workaround will break other functionalities, like Microsoft IME and inserting emoji icons. 

Thank you for your understanding.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

ADMIN
Martin Ivanov
Posted on: 21 Jan 2026 12:46

Hello Valentin,

This is not included in the current planning and I can't provide you with a specific timeframe for fixing this. You can follow the feedback item to get notified as its status changes. 

In the meantime, if you need to add speech input in the RadRichTextBox, you can use the new RadSpeechToTextButton which was just released.

You can disable the Win+H voice typing for the RadRichTextBox by setting the InputMethod.IsInputMethodEnabled attached property to False. You can set it on the Caret element via an implicit style.

<telerik:RadRichTextBox>
    <telerik:RadRichTextBox.Resources>
        <!-- remove the BasedOn setting if you use the Xaml version of the Telerik dlls -->
        <!-- https://www.telerik.com/products/wpf/documentation/styling-and-appearance/xaml-vs-noxaml -->
        <Style TargetType="telerik:Caret" BasedOn="{StaticResource CaretStyle}">
            <Setter Property="InputMethod.IsInputMethodEnabled" Value="False" />
        </Style>
    </telerik:RadRichTextBox.Resources>
</telerik:RadRichTextBox>

This way when you show the voice typing dialog while the RichTextBox is focused, a message similar to the following will be displayed:

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Valentin
Posted on: 14 Jan 2026 19:47
Hi Martin, are there any news regarding plans to fix this?