Open yll690 opened 1 month ago
@yll690 See @walterlv 's blog:
To achieve your desired effect, you only need to set the width of the TextBlock.
<TextBlock Text="1111111111111111111111111" Width="auto" MaxWidth="100" TextWrapping="Wrap"/>
Definitely it's a bug.
"Definitely" is a strong word. The documentation says:
If a child element is added to a column within a Grid, and the column has its Width property set to Auto, the child will be measured without restrictions. This behavior can prevent horizontal scroll bars from displaying if a ScrollViewer is being used, as the child element is measured as unbounded. For purposes of display, the child is clipped rather than scrolled.
That is consistent with the behavior shown.
Well the column doesn't exceed it right? You can't see the control beyond 100, it is measured as unbounded and then clipped, like it said.
I am not saying this is right or intuitive, rather pointing out that it is not as clear cut and applications might depend on this (documented) behavior.
Description
Control's size is incorrect when in a grid column with Width="auto" and MaxWidth="100"
Reproduction Steps
MainWindow.xaml
Expected behavior
The TextBlock's width should be 100 and the text should be wrapped. If I drag the GridSplitter, The width of TextBlock becomes correct.
Actual behavior
The TextBlock's width is its desired width and the text is not wrapped.
Regression?
No response
Known Workarounds
No response
Impact
No response
Configuration
No response
Other information
No response