I'm trying to create a chat application. I'm trying to display a series of text in a Label
wrapped inside a Grid
.
<Grid Grid.Row="2">
<Grid Margin="0,0,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Width="auto" MaxWidth ="300" Height="auto" HorizontalAlignment="Left" Margin="10,5,0,0" ScrollViewer.CanContentScroll="True">
<Grid.Background>
<ImageBrush ImageSource="Public\Images\chat_green-textarea.png"/>
</Grid.Background>
<Label Padding="5,0,5,5" Foreground="White" FontSize="15">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</Label>
</Grid>
</Grid>
<Image Source="Public\Images\chat_green-textarea-tail.png" Height="20" Width="30" VerticalAlignment="Top" Margin="-20,29.5,0,0"/>
</Grid>
</Grid>
As you can see I set a max width hoping that when the text in the label reached this width, the grid will adjust its height as to process all the text inside the label. But it won't work. This is my first time to try WPF
. Any ideas and suggestions? Thanks!