C# 为什么我的flipview不显示任何图片?

C# 为什么我的flipview不显示任何图片?,c#,xaml,windows-runtime,bitmapimage,flipview,C#,Xaml,Windows Runtime,Bitmapimage,Flipview,目前,我可以选择多个文件,但当我单击“打开”时,所选图像不会显示。相反,“Windows.UI.XAML.Media.Imaging.BitmapImage”显示为文本。不过,FlipView功能仍然存在。我做错了什么 XAML 在代码后面 public async Task flipviewload() { // Add code to perform some action here. Windows.Storage.Pickers.FileOpenPicker open

目前,我可以选择多个文件,但当我单击“打开”时,所选图像不会显示。相反,“Windows.UI.XAML.Media.Imaging.BitmapImage”显示为文本。不过,
FlipView
功能仍然存在。我做错了什么

XAML


在代码后面

public async Task flipviewload()
{
    // Add code to perform some action here.
    Windows.Storage.Pickers.FileOpenPicker openPicker = new Windows.Storage.Pickers.FileOpenPicker();
    openPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
    openPicker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;

    // Filter to include a sample subset of file types.
    openPicker.FileTypeFilter.Clear();
    openPicker.FileTypeFilter.Add(".bmp");
    openPicker.FileTypeFilter.Add(".png");
    openPicker.FileTypeFilter.Add(".jpeg");
    openPicker.FileTypeFilter.Add(".jpg");
    var files = await openPicker.PickMultipleFilesAsync();

    var images = new List<BitmapImage>();
    if (files != null)
    {
        //foreach (StorageFile Images in files)
        foreach (var file in files)
        {
            Windows.Storage.Streams.IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
            using (Windows.Storage.Streams.IRandomAccessStream filestream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
            {
                BitmapImage bitmapImage = new BitmapImage();
                await bitmapImage.SetSourceAsync(fileStream);
                //Images.Source = bitmapImage;
                images.Add(bitmapImage);
            }
        }
    }
    flpView.ItemsSource = images;
}
公共异步任务flipviewload()
{
//在此处添加代码以执行某些操作。
Windows.Storage.Pickers.FileOpenPicker-openPicker=新的Windows.Storage.Pickers.FileOpenPicker();
openPicker.SuggestedStartLocation=Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
openPicker.ViewMode=Windows.Storage.Pickers.PickerViewMode.Thumbnail;
//筛选以包括文件类型的示例子集。
openPicker.FileTypeFilter.Clear();
openPicker.FileTypeFilter.Add(“.bmp”);
openPicker.FileTypeFilter.Add(“.png”);
openPicker.FileTypeFilter.Add(“.jpeg”);
openPicker.FileTypeFilter.Add(“.jpg”);
var files=等待openPicker.PickMultipleFileAsync();
var images=新列表();
如果(文件!=null)
{
//foreach(存储文件中的文件映像)
foreach(文件中的var文件)
{
Windows.Storage.Streams.irandomaccesstream fileStream=await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
使用(Windows.Storage.Streams.irandomaccesstream filestream=await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
{
BitmapImage BitmapImage=新的BitmapImage();
等待bitmapImage.SetSourceAsync(文件流);
//image.Source=位图图像;
添加(位图图像);
}
}
}
flpView.ItemsSource=图像;
}

我还添加了
Task foo=flipviewload()在我的公共
MainPage()中

之所以会得到这个结果,是因为默认呈现调用了项上的
ToString()
,该项将打印类的名称。如果要显示图像,必须提供
ItemTemplate

<FlipView x:Name="flpView" Grid.Row="1" Margin="10, 10, 10, 10">
    <FlipView.ItemTemplate>
        <DataTemplate>
            <Image Stretch="UniformToFill" Source="{Binding}" />
        </DataTemplate>
    </FlipView.ItemTemplate>
</FlipView>

<FlipView x:Name="flpView" Grid.Row="1" Margin="10, 10, 10, 10">
    <FlipView.ItemTemplate>
        <DataTemplate>
            <Image Stretch="UniformToFill" Source="{Binding}" />
        </DataTemplate>
    </FlipView.ItemTemplate>
</FlipView>