TextBlock.TextWrapping="Wrap" doesn't wrap and changes the layout of my window
See original GitHub issueAvalonia window without the TextBlock at the top:
Avalonia window with the TextBlock (note the result is the same if I set TextWrapping="Wrap"
on the TextBlock):
Same code in WPF without TextWrapping="Wrap"
:
Same code in WPF with TextWrapping="Wrap"
:
Notice how WPF doesn’t shift the contents outside of the bounds of the window - regardless of whether I have set TextWrapping="Wrap"
or not.
Here is my code:
<Window x:Class="MyProjectWPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MyProjectWPF"
mc:Ignorable="d"
Title="MainWindow" MaxWidth="300" Height="420">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="Describe the bug and what you were doing when you encountered it" TextWrapping="Wrap" Margin="5"/>
<TextBox Grid.Row="1" Width="NaN" Height="200" Text="{Binding Description}"
TextWrapping="Wrap" AcceptsReturn="True" Margin="5"/>
<DockPanel Grid.Row="2">
<TextBlock Text="Your name:" Margin="5"/>
<TextBox Text="{Binding Name}" Margin="5"/>
</DockPanel>
<DockPanel Grid.Row="3">
<TextBlock Text="Email:" Margin="5"/>
<TextBox Text="{Binding Email}" Width="NaN" Margin="5"/>
</DockPanel>
<StackPanel Grid.Row="4">
<RadioButton Content="Bug Report" Margin="5"/>
<RadioButton Content="Feature Request" Margin="5"/>
</StackPanel>
<TextBlock Grid.Row="5" HorizontalAlignment="Left" Text="--LOG FILES ATTACHED--"
Background="Green" FontWeight="Bold" Margin="5"/>
<Button Grid.Row="5" HorizontalAlignment="Right" Content="Submit" Command="{Binding Submit}" Margin="5"/>
</Grid>
</Window>
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
TextBlock TextWrapping not wrapping - wpf
Because there's nothing to constrain the width of the TextBlock, it doesn't wrap. If you switch to Vertical orientation then the wrapping ...
Read more >Text Wrapping Issue
It seems I need to change the illustration's layout option. ... No, inserting text-wrapping breaks into the document doesn't fix this.
Read more >Sizing issues when using TextBlock with TextWrapping ...
I am using a TextBlock element with TextWrapping="Wrap" in a LayoutControlItem and I cannot get the automatic sizing to work properly.
Read more >How to change TEXT WRAPPING in Word - YouTube
Text wrapping can be customised with margins and layouts as well as fixing your item in position within your document.
Read more >Learn how to wrap text around objects in InDesign
Navigate to the Text Wrap panel, select Window > Text Wrap. · Import the image and prepare the text that you would want...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As a workaround for 0.9, instead of
<Grid ColumnDefinitions="*">
You can put binding there<Grid Width="{Binding $parent[Window].Bounds.Width}">
FYI: This workaround fixes the problem on windows but causes a bug under Linux making the Window always being large. A screenshot is available at https://github.com/0x90d/videoduplicatefinder/issues/212#issue-1007183950