如何绑定列表项以在Windows Phone中包装面板

时间:2014-03-25 05:39:23

标签: c#-4.0 windows-phone-8

如何将列表项绑定到Wrap Panel, 我得到的结果如下:

1 2 3 4

但我想这样:

1 2 3 4 5 6 7 8

1 个答案:

答案 0 :(得分:0)

            <ListBox.ItemTemplate>
                <DataTemplate>

                        <StackPanel Orientation="Vertical">

                            <Image Source="{Binding Icon}" Stretch="Uniform" HorizontalAlignment="Center" Height="50" Width="100"/>

                            <TextBlock Text="{Binding Name}" TextWrapping="Wrap" Foreground="White" FontSize="22" Height="30" Margin="10" Width="110" TextAlignment="Center"/>

                        </StackPanel>

                </DataTemplate>
            </ListBox.ItemTemplate>

            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <Controls:WrapPanel/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
        </ListBox>