Align listbox items horizontally
I want to show a listbox with two items for each row.
You can see an example here.
I have the following XAML:
<Grid x:Name="FriendsGrid">
<ListBox x:Name="FriendsList" Margin="0" ItemTemplate="{StaticResource FriendsDataTemplate}"/>
</Grid开发者_开发百科>
<DataTemplate x:Key="FriendsDataTemplate">
<Grid VerticalAlignment="Top" HorizontalAlignment="Right" Background="{StaticResource PhoneAccentBrush}">
<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>
</DataTemplate>
But I see one ListBoxItem for each row.
How can I do that?
Can you not just use a WrapPanel
as the ItemContainerStyle
?
精彩评论