将面板包裹在列表框中
我有以下 XAML 代码:
<DataTemplate x:Key="FriendsDataTemplate">
<toolkit:WrapPanel Orientation="Horizontal" ItemWidth="173" ItemHeight="233">
<Grid VerticalAlignment="Top" HorizontalAlignment="Right">
<Grid.RowDefinitions>
<RowDefinition Height="183"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Image x:Name="FriendAvatar" Margin="1,1,11,11" Source="{Binding ImageURL}" Width="173" Height="173"/>
<Grid Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Top">
<TextBlock x:Name="FriendName" Margin="0" Text="{Binding FriendName}" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="0,0,10,0" TextAlignment="Right"/>
</Grid>
</Grid>
</toolkit:WrapPanel>
</DataTemplate>
<Grid x:Name="FriendsGrid">
<ListBox x:Name="FriendsList" Margin="0" ItemTemplate="{StaticResource FriendsDataTemplate}"/>
</Grid>
FriendsList
宽度为 420px。
我的问题是:我想要两个项目列,但我看到一个。
有什么建议吗?
I have the following XAML code:
<DataTemplate x:Key="FriendsDataTemplate">
<toolkit:WrapPanel Orientation="Horizontal" ItemWidth="173" ItemHeight="233">
<Grid VerticalAlignment="Top" HorizontalAlignment="Right">
<Grid.RowDefinitions>
<RowDefinition Height="183"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Image x:Name="FriendAvatar" Margin="1,1,11,11" Source="{Binding ImageURL}" Width="173" Height="173"/>
<Grid Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Top">
<TextBlock x:Name="FriendName" Margin="0" Text="{Binding FriendName}" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="0,0,10,0" TextAlignment="Right"/>
</Grid>
</Grid>
</toolkit:WrapPanel>
</DataTemplate>
<Grid x:Name="FriendsGrid">
<ListBox x:Name="FriendsList" Margin="0" ItemTemplate="{StaticResource FriendsDataTemplate}"/>
</Grid>
FriendsList
width is 420px.
My problem is: I want two items column, but I see one.
Any advice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决方案。这是我的工作 XAML 代码:
我在
ListBox
定义中添加了一个ListBox.ItemsPanel
。我已经将包裹面板移到了上面。I've found the solution. Here is my working XAML code:
I've added a
ListBox.ItemsPanel
insideListBox
definition. And I've moved wrap panel on it.