Question

below is my xaml structure:

 <Grid>        
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*" />         
        </Grid.RowDefinitions>
        <TextBlock Text = "{Binding Test}" />
        <GroupBox Header = "Test" Grid.Row="1">
             <TextBlock Text = "{Binding Description}" />
        </GroupBox>
 </Grid>

My Description is very long, but there's no vertical scrollviewer display in my groupbox. I don't want to set a specific height to the groupbox. Anyone can help?

Was it helpful?

Solution

You can set TextWrapping="Wrap" and wrap it in ScrollViewer with HorizontalScrollBarVisibility="Disabled":

<Grid>
   <Grid.RowDefinitions>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="*" />
   </Grid.RowDefinitions>
   <TextBlock Text="{Binding Test}" />
   <GroupBox Header="Test" Grid.Row="1">
      <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
         <TextBlock TextWrapping="Wrap" Text="{Binding Description}" />
      </ScrollViewer>
   </GroupBox>       
</Grid>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top