TextWrapping 不适用于水平 StackPanel
我有一个全景项目
<controls:PanoramaItem Header="Stream" Margin="0,-16,0,0">
<ListBox Margin="0,-16,0,0" ItemsSource="{Binding Items}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="6,0,0,10">
<StackPanel Margin="6,0,0,10" Orientation="Horizontal">
<Image Source="{Binding ProfileImage}"
VerticalAlignment="Top"
Margin="0,4,0,0"
Width="48" Height="48"
/>
<!-- This doesn't work -->
<TextBlock Text="{Binding ProfileName}"
TextWrapping="Wrap"
Style="{StaticResource PhoneTextTitle2Style}"/>
<TextBlock Text="{Binding RelativeTime}"
Margin="2,10,0,2"
Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
<!-- This works -->
<StackPanel Margin="0,-4,0,17" Orientation="Vertical">
<TextBlock Text="{Binding Content}"
TextWrapping="Wrap"
Style="{StaticResource PhoneTextNormalStyle}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</controls:PanoramaItem>
,需要使 ProfileName
文本换行,如果可能的话,我希望使 RelativeTime
向右浮动。
我该怎么做呢?
I have a panorama item
<controls:PanoramaItem Header="Stream" Margin="0,-16,0,0">
<ListBox Margin="0,-16,0,0" ItemsSource="{Binding Items}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="6,0,0,10">
<StackPanel Margin="6,0,0,10" Orientation="Horizontal">
<Image Source="{Binding ProfileImage}"
VerticalAlignment="Top"
Margin="0,4,0,0"
Width="48" Height="48"
/>
<!-- This doesn't work -->
<TextBlock Text="{Binding ProfileName}"
TextWrapping="Wrap"
Style="{StaticResource PhoneTextTitle2Style}"/>
<TextBlock Text="{Binding RelativeTime}"
Margin="2,10,0,2"
Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
<!-- This works -->
<StackPanel Margin="0,-4,0,17" Orientation="Vertical">
<TextBlock Text="{Binding Content}"
TextWrapping="Wrap"
Style="{StaticResource PhoneTextNormalStyle}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</controls:PanoramaItem>
I need to make ProfileName
text wrap and I would like, if possible, to make RelativeTime
to float right.
How can I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是有道理的,在水平 StackPanel 中,没有明显的宽度约束来使 Textblock 换行。您可以添加这样的约束,但这需要提供像素。
只要看看 XAML,我想您可能想要一个具有 3 列的网格,而不是 StackPanel。
Makes sense, in a horizontal StackPanel there is no obvious Width constraint to make the Textblock wrap. You could add such a constraint, but that requires providing Pixels.
Just looking at the XAML I think that maybe you want a Grid with 3 columns here, not a StackPanel.