希望得到一個多個列的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.