我正在尝试创建一个聊天应用程序。Label
我正在尝试在一个包裹内显示一系列文本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>
如您所见,我设置了最大宽度,希望当标签中的文本达到此宽度时,网格将调整其高度以处理标签内的所有文本。但它不会起作用。这是我第一次尝试WPF
。有什么想法和建议吗?谢谢!