我有一个显示消息的WPF列表框。它包含一个头像在左边,用户名和消息垂直堆叠在头像的右边。在消息文本应该自动换行之前,布局是很好的,但是我在列表框上看到了一个水平滚动条。
我在谷歌上搜索并找到了类似问题的解决方案,但都没有奏效。
<ListBox HorizontalContentAlignment="Stretch" ItemsSource="{Binding Path=FriendsTimeline}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Border BorderBrush="DarkBlue" BorderThickness="3" CornerRadius="2" Margin="3" >
<Image Height="32" Width="32" Source="{Binding Path=User.ProfileImageUrl}"/>
</Border>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Path=User.UserName}"/>
<TextBlock Text="{Binding Path=Text}" TextWrapping="WrapWithOverflow"/> <!-- This is the textblock I'm having issues with. -->
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
https://stackoverflow.com/questions/397257
复制相似问题