希望得到一个多个列的listBox,每个单元都是ListBox的一个Item, 效果图如下:

 

对应的xaml:

                    <Grid x:Name="LoginNoSubsPanel" Visibility="Visible">
                        <ListBox x:Name="HotKeywordsListBox"
                                 ItemsSource="{Binding RecommendedTopicsLeft}">
                            <ListBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <toolkit:WrapPanel  ItemHeight="176" ItemWidth="176"/>
                                </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Grid Margin="20,0,0,20">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="*"/>
                                        </Grid.RowDefinitions>
                                        <Image Grid.Row="0" Source="{Binding ImageSource}" 
                                               Height="140" Width="176" Margin="0"
                                               Stretch="Uniform"/>
                                        <Button Grid.Row="0" HorizontalAlignment="Center" 
                                                VerticalAlignment="Center" Margin="0" Padding="0"
                                                BorderThickness="0">
                                            <Button.Content>
                                                <Image Source="/Assets/BtnIcons/unchoose_2.png"
                                                       Width="36" Height="36"/>
                                            </Button.Content>
                                        </Button>
                                        <TextBlock Grid.Row="1" Text="{Binding KeyWords}" 
                                               FontSize="{StaticResource PhoneFontSizeNormal}"/>
                                        <Rectangle Grid.RowSpan="2" Stroke="Gray"/>
                                    </Grid>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </Grid>

设置ItemsPanel, 用到了 toolkit:WrapPanel.

posted on 2013-01-23 21:18  桃源月色  阅读(579)  评论(0编辑  收藏  举报