question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TextBlock.TextWrapping="Wrap" doesn't wrap and changes the layout of my window

See original GitHub issue

Avalonia 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:closed
  • Created 3 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
maxkatz6commented, Oct 17, 2020

As a workaround for 0.9, instead of <Grid ColumnDefinitions="*"> You can put binding there <Grid Width="{Binding $parent[Window].Bounds.Width}">

0reactions
0x90dcommented, Sep 25, 2021

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found