microsoft-ui-xaml icon indicating copy to clipboard operation
microsoft-ui-xaml copied to clipboard

Unable to use TextWrapping="WrapWholeWords" on TextBox elements

Open julienshepherd opened this issue 2 years ago • 1 comments

Describe the bug

Setting TextWrapping="WrapWholeWords" in Xaml causes an exception in InitializeComponent().

Steps to reproduce the bug

  1. Start Visual Studio 2022 (latest version, 17.2.0 at the time of writing), select "Create a new project", select "Blank App (Universal Windows)" in C#, then click Create.
  2. Leave the versions as default. At the time of writing they are: target version - Windows 10, version 2004, minimum version - Windows 10, version 1809. Click OK.
  3. In MainPage.xaml, add a TextBox with property TextWrapping="WrapWholeWords".
  4. In Visual Studio, click Local Machine to debug the app.
  5. Notice the exception:

Windows.UI.Xaml.Markup.XamlParseException: 'The text associated with this error code could not be found.

E_RUNTIME_SETVALUE [Line: 12 Position: 18]'

Expected behavior

No response

Screenshots

No response

NuGet package version

No response

Windows app type

  • [ ] UWP
  • [ ] Win32

Device form factor

No response

Windows version

No response

Additional context

No response

julienshepherd avatar May 15 '22 06:05 julienshepherd

I have same problem too. TextWrapping value Wrap is okay.

JanRajnoha avatar Aug 06 '22 14:08 JanRajnoha

I was going nuts trying to convert a TextBlock with this property to TextBox and had no idea what was going on. This error is very cryptic and happening during layout. Lost a couple of hours of fiddling due to this as I was trying to restyle the template and thought it had something to do with that.

hawkerm avatar Aug 30 '22 03:08 hawkerm

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jul 28 '23 22:07 github-actions[bot]

Problem is still in latest public version of Win App SDK.

JanRajnoha avatar Aug 03 '23 21:08 JanRajnoha

Just encountered this issue and it too wasted my hours. Still exist in Winui 2.8.5

HO-COOH avatar Aug 30 '23 07:08 HO-COOH

TextBox and RichEditBox don't support the WrapWholeWords value for their TextWrapping properties.

See 'Remarks' section: https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.textwrapping?view=winrt-22621

DFX-Coding avatar Sep 12 '23 16:09 DFX-Coding

okay, than which control can and if none, why is it still there?

JanRajnoha avatar Sep 12 '23 19:09 JanRajnoha

TextBlock & RichTextBlock

kmgallahan avatar Sep 13 '23 00:09 kmgallahan

OK, but TextBox and RichTextBox is basically a TextBlock and RichTextBlock respectively when it is not in editing mode. How hard is it to bring the wrapping mode to them?

HO-COOH avatar Sep 13 '23 06:09 HO-COOH

This is a known limitation of TextBox. See the Remarks section of the docs on TextBox.TextWrapping Property.

kmahone avatar Sep 21 '23 18:09 kmahone

@kmahone Unless I'm mistaken, did TextBox & RichTextBox recently get updated to exhibit the WrapWholeWords behavior by default (without setting TextWrapping explicitly)?

kmgallahan avatar Nov 05 '23 18:11 kmgallahan