Undiscouraged
Undiscouraged

Reputation: 1125

XAML TextBlock wrapping does not work

I know this was already asked a couple of times but I can't get it working. I have a data template which is used inside a listbox. Unfortunately the text and the name extends over the right border. I already tried with '*' and 'Auto' for the row definition. Can somebody tell me what I am doing wrong here?

<Border Padding="10">
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>

    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="0" >
        <TextBlock Text="{Binding Name}" TextWrapping="Wrap" />
        <TextBlock Text="{Binding Created, Mode=OneWay}"/>
    </StackPanel>

    <TextBlock Grid.Column="0" Grid.Row="1" Margin="0,6,0,0" Text="{Binding Text}" TextWrapping="Wrap"/>
</Grid>

Upvotes: 0

Views: 1823

Answers (1)

Hutjepower
Hutjepower

Reputation: 1261

It looks like you are confusing the width and height here. You have set only one columndefinition with a width for all remaining space (complete width). You could add another column or specify the width of your textblock to assure TextWrapping will take place...

Upvotes: 3

Related Questions