WPF: Text wrapping not working

Posted by Ben on Stack Overflow See other posts from Stack Overflow or by Ben
Published on 2009-05-10T15:13:04Z Indexed on 2010/05/12 11:04 UTC
Read the original article Hit count: 287

Filed under:
|
|

I've got a grid defined simply:

<Grid Margin="0,5,0,0">
  <Grid.ColumnDefinitions>
    <ColumnDefinition Width="50"></ColumnDefinition>
    <ColumnDefinition Width="50"></ColumnDefinition>
    <ColumnDefinition Width="48"></ColumnDefinition>
    <ColumnDefinition Width="Auto"></ColumnDefinition>
   </Grid.ColumnDefinitions>

Then I'm trying to bind some content like this:

<TextBlock TextWrapping="Wrap" Grid.Column="3" Text="{Binding Text}">

Set up like this, the text won't wrap. It simply expands the column to fit the text. If I set the Width to a fixed amount on the last column, wrapping works as expected. The problem there is that if the user widens the window, the column stays at a fixed size. How can I get the column to size dynamically with the width of the grid, but still wrap the text within it?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about wrap