Open nzstevem opened 3 years ago
@RealTommyKlein and @fabiant3 FYI
@nzstevem is this issue exclusive to Preview4?
I'm not absolutely sure if the issue was introduced with Preview4 but I think NOT. From memory I applied PV4 thinking that might clear the issue. Now I've installed PV4 in VS I'm not sure how to go back.
The error message could definitely be better, but WrapWholeWords is an unsupported value for TextBox. From TextBox.TextWrapping docs:
TextBox and RichEditBox don't support the WrapWholeWords value for their TextWrapping properties. If you try to use WrapWholeWords as a value for TextBox.TextWrapping or RichEditBox.TextWrapping, an exception is thrown.
The situation is made worse by the fact that VS doesn't complain during either edit or build.
I've struck a number of issues of this type where code flies through VS intellisense and then build and then fails during execution with an error message that gives no clue as to where the issue lies.
Even in code the TextWrapping Enum includes the WrapWholeWords item. Perhaps it needs a TextBoxTextWrapping Enum to avoid confusion with TextBlock.
It took me hours to work out what was causing the issue. Given it had sailed through VS I immediately assumed it was a library/version issue or a bug. After messing around and updating to very latest I then started peeling out options and eventually found by a process of elimination what was triggering the error. These sort of issues are a real headache when you are still trying to get to grips with the framework as I am.
BUT...
The real confusion here is that TextWrapping="Wrap" actually wraps whole words! it does NOT character wrap!!!!
So why WholeWords is not supported when Wrap does just this is confusing. It is Character wrap that is not supported!
You're right, it does seem like it should reject Wrap rather than WrapWholeWords. It could probably also be argued that it should just accept either value even if it only wraps as whole words currently -- that might be better than rejecting a value only via exception at runtime.
I would have thought an option to just wrap at a character level with no sensitivity to "words" or spaces would be a simple and obvious first option.
The more complex option (which appears to be what we have) is to wrap on word boundaries. I note in a TEXTBLOCK with the WrapWholeWords option when the word won't fit on its own line it truncates the long word and the next line starts with the next word. You wouldn't want to be keying into a TextBox and not be able to see what you entered! So this option might be better named "OnlyWrapAtWordEnd".
A TextBox WrapWholeWords needs to wrap on space when it can but be prepared to character wrap when there is no other choice.
This is like a lot of things. More complex the longer you look at it! :-)
This is still an issue as of the current version of WinUI3 (via Windows App SDK)
Its totally unacceptable that a simple character wrap is not possible in WinUI ATM. The TextWrapping.Wrap
does word wrap wasting a lot of space and TextWrapping.WrapWholeWords
does a miserable wrap. Just see below to believe this is the same multi line TextBlock
with WordEllipsis
and same Text
.. only the TextWrapping
property changed:
Just found this open issue, glad too but I wasted about an hour trying to debug this XAML parsing error before finding it.
Describe the bug Simple MainWindow XML code as follows. NO code behind. When run in VS generated XML parsing exception.
<Window x:Class="Test77.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:Test77" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
Steps to reproduce the bug
Expected behavior Expected the app to run and demonstrate resizing and re-wrapping of center column.
Also noticed that when the app is run with the center column TextWrapping="Wrap" that the TextBox and Border shrink as the page window is reduced as expected. But when the window is then expanded back the center Border/TextBox does not expand back to its original size.
Screenshots
Exception screen...
Running app with WrapWholeWords changed to Wrap looks as expected
Second image after window reduced in width and then expanded - the center TextBox doesn't re-size and re-wrap????
Version Info Edition Windows 10 Pro Version 20H2 Installed on 16/07/2020 OS build 19042.804 Experience Windows Feature Experience Pack 120.2212.551.0
NuGet package version: [Microsoft.WinUI 3.0.0-preview4.210210.4] -->
Additional context