Home > DeveloperSection > Forums > Column Widths and a TextBlock Sizing in WPF
lois waisbrooker
lois waisbrooker

Total Post:70

Points:494
Posted on    July-18-2013 11:46 PM

 WPF WPF 
Ratings:


 1 Reply(s)
 1266  View(s)
Rate this:
Hi developers!

I have a grid in xaml that has two columns with widths 4.5* and 5.5*

In column 1 i have a textblock. When this textblock has text that is very long it is making the textblock column very wide and my second column is getting smaller.

I need the textblock column to stay the wide that is set and wrap the text instead.

Here is the xaml:

<Grid>

    <Grid.RowDefinitions>

        <RowDefinition Height="25"  />

    </Grid.RowDefinitions>

    <Grid.ColumnDefinitions>

        <ColumnDefinition Width="4.5*"/>

        <ColumnDefinition Width="5.5*"/>

    </Grid.ColumnDefinitions>

    <TextBlock x:Name="lblCheck" Text="{Binding Path=Text}"  Grid.Column="0"  Grid.Row="0" TextWrapping="Wrap" Margin="5,0,0,0"/>

    <CheckBox x:Name="chkOption" Grid.Column="1" IsChecked="{Binding Path=Checked}" Grid.Row="0"  IsEnabled="True"/>

</Grid>

Thanks



shreesh chandra shukla
shreesh chandra shukla

Total Post:105

Points:735
Posted on    July-19-2013 12:16 AM

Solution!

The code you posted works fine, other than the fact your RowHeight is set to 35 so it only shows at most 2 lines of text for me.

Try setting your RowHeight to *



Don't want to miss updates? Please click the below button!

Follow MindStick