UWP TextBox Wrapping: ArgumentException - The parameter is incorrect.


You're attempting to set the TextWrapping property on a UWP TextBox and you encouter the following exception.


System.ArgumentException: 'The parameter is incorrect. E_RUNTIME_SETVALUE'

C# (Not working)

private void MenuWordWrap_Click(object sender, RoutedEventArgs e)
    if (MenuWordWrap.IsChecked)
        TextBoxMain.TextWrapping = TextWrapping.WrapWholeWords;
        TextBoxMain.TextWrapping = TextWrapping.NoWrap;

Cause and Fix:

The issue in this case occurs because the TextBox control does not support the TextWrapping.WrapWholeWords enumeration. Not all controls that implement word wrapping implement all of the options and the TextBox is one of them. This is also true of the RichEditBox control.

To fix the error you will want to change TextWrapping.WrapWholeWords to the following:

TextBoxMain.TextWrapping = TextWrapping.Wrap;

Additional Info

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.