문제

현재 여러 파일을 선택할 수 있지만 열기를 클릭하면 선택한 이미지가 표시되지 않습니다.대신 "Windows.UI.XAML.Media.Imaging.BitmapImage"가 텍스트로 나타납니다.그만큼 FlipView 기능은 여전히 ​​존재합니다.내가 도대체 ​​뭘 잘못하고있는 겁니까?

XAML.

<FlipView x:Name="flpView" Grid.Row="1" Margin="10, 10, 10, 10">
    <Image x:Name="images" Stretch="UniformToFill" />
</FlipView>

코드 뒤에.

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;
}

나도 추가했다 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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top