xamlwindows-phone-8itemtemplate

Windows Phone 8 more Items in row as template


I'm new in Windows Phone 8 development and I want to create a page with any number of items sorted in two columns as this great image shows.

template

I was trying to use LongListSelector, but i was able to create only one column. So what control should I use to create such a template?


Solution

  • install windows phone toolkit

    add this code in your xaml in phone:PhoneApplicationPage

    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    

    this is your list code

    <ListBox x:Name="pictureListBox" Margin="10,101,10,10" ItemsSource="{Binding}" SelectionChanged="pictureListBox_SelectionChanged_1">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <toolkit:WrapPanel/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical" >
                            <Image x:Name="Image" Source="{Binding Thumb}" Stretch="Uniform" Width="200" Height="200" Margin="10"/>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>