C# 在FlipView中绑定2个图像

C# 在FlipView中绑定2个图像,c#,xaml,windows-store-apps,windows-8.1,flipview,C#,Xaml,Windows Store Apps,Windows 8.1,Flipview,我在这里也有同样的问题: 除此之外,我已将FlipView.ItemTemplate绑定到一个UserControl上,该控件具有两个图像。 为了能够从MainPage.xaml.cs访问绑定的ImageSource,我在App.xaml.cs中创建了两个全局变量: public static ImageSource Image1 { get; set; } public static ImageSource Image2 { get; set; } public static new Ap

我在这里也有同样的问题:

除此之外,我已将
FlipView.ItemTemplate
绑定到一个
UserControl
上,该控件具有两个图像。 为了能够从MainPage.xaml.cs访问绑定的
ImageSource
,我在App.xaml.cs中创建了两个全局变量:

public static ImageSource Image1 { get; set; }
public static ImageSource Image2 { get; set; }

public static new App Current
{
    get { return Application.Current as App; }
}
我可以这样设置第一个图像:

flipView.Items.Add(new Uri(BaseUri, Images[0]));
但如果以这种方式绑定图像,则即使是flipView也不会显示任何内容:

App.Image1 = new BitmapImage(new Uri("ms-appx:///Assets/Images/page0.jpg"));
我应该如何以从数组中自动连续生成的方式绑定它们?

创建一个新类:

public class MyImage
{
     public ImageSource Image1 { get; set; }
     public ImageSource Image2 { get; set; }
}
在您的页面中,您必须以
列表的形式加载图像(如果索引为奇数,则myImage.Image1=yourImage,否则myImage.Image2=yourImage)

然后,在用户控件中,将图像绑定到Image1和Image2,并将翻转的ItemsSource设置为
列表