microsoft-ui-xaml
microsoft-ui-xaml copied to clipboard
Unable to use TextWrapping="WrapWholeWords" on TextBox elements
Describe the bug
Setting TextWrapping="WrapWholeWords"
in Xaml causes an exception in InitializeComponent()
.
Steps to reproduce the bug
- 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.
- 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.
- In MainPage.xaml, add a TextBox with property TextWrapping="WrapWholeWords".
- In Visual Studio, click Local Machine to debug the app.
- 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
I have same problem too. TextWrapping value Wrap is okay.
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.
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.
Problem is still in latest public version of Win App SDK.
Just encountered this issue and it too wasted my hours. Still exist in Winui 2.8.5
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
okay, than which control can and if none, why is it still there?
TextBlock & RichTextBlock
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?
This is a known limitation of TextBox. See the Remarks section of the docs on TextBox.TextWrapping Property.
@kmahone Unless I'm mistaken, did TextBox & RichTextBox recently get updated to exhibit the WrapWholeWords behavior by default (without setting TextWrapping
explicitly)?