1

我目前正在为 Windows Phone 的时尚商店应用程序开发一个项目。对于目录,我需要创建一个图片库,如果您在其中垂直滚动,您会看到与同一产品相关的图片,如果您横向滚动,您将看到下一个/上一个产品。

我首先创建了一个 3x3 图像的小概念画廊。一列是飞机,第二辆坦克和第三艘战舰。我使用了 1 个水平 FlipView,其中包含 3 个垂直 FlipView 作为项目。

这是 XAML 代码:

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <FlipView x:Name="flipBase">
        <FlipView x:Name="a">
            <FlipView.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel Orientation="Vertical" />
                </ItemsPanelTemplate>
            </FlipView.ItemsPanel>
        </FlipView>
        <FlipView x:Name="b">
            <FlipView.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel Orientation="Vertical" />
                </ItemsPanelTemplate>
            </FlipView.ItemsPanel>
            </FlipView>
        <FlipView x:Name="c">
            <FlipView.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel Orientation="Vertical" />
                </ItemsPanelTemplate>
            </FlipView.ItemsPanel>
            </FlipView>
    </FlipView>
</Grid>

这是 C# 代码: public seal partial class MainPage : Page { public MainPage() { this.InitializeComponent();

        //PRIMEIRA COLUMNA
        Image foto = new Image();
        foto.Source = new BitmapImage(new Uri("ms-appx:///Assets/plane/plane_spitfire.jpg"));
        a.Items.Add(foto);

        foto = new Image();
        foto.Source = new BitmapImage(new Uri("ms-appx:///Assets/plane/plane_stuka.jpg"));
        a.Items.Add(foto);

        foto = new Image();
        foto.Source = new BitmapImage(new Uri("ms-appx:///Assets/plane/plane_yak9.jpg"));
        a.Items.Add(foto);

        //SEGUNDA COLUMNA
        foto = new Image();
        foto.Source = new BitmapImage(new Uri("ms-appx:///Assets/tank/tank_IS.jpg"));
        b.Items.Add(foto);

        foto = new Image();
        foto.Source = new BitmapImage(new Uri("ms-appx:///Assets/tank/tank_Patton.jpg"));
        b.Items.Add(foto);

        foto = new Image();
        foto.Source = new BitmapImage(new Uri("ms-appx:///Assets/tank/tank_Tiger.jpg"));
        b.Items.Add(foto);

        //TERCEIRA COLUMNA
        foto = new Image();
        foto.Source = new BitmapImage(new Uri("ms-appx:///Assets/destroyer/destroyer_german.jpg"));
        c.Items.Add(foto);

        foto = new Image();
        foto.Source = new BitmapImage(new Uri("ms-appx:///Assets/destroyer/destroyer_russian.jpg"));
        c.Items.Add(foto);

        foto = new Image();
        foto.Source = new BitmapImage(new Uri("ms-appx:///Assets/destroyer/destroyer_usa.jpg"));
        c.Items.Add(foto);

    }
}

我有两个主要问题:-有更好的方法吗?(一个允许我动态添加列和项目) - 当检测到垂直移动时如何限制水平移动,反之亦然(防止对角线移动)?

这是我在此的头一篇博文。非常感谢您的回答!

4

0 回答 0