簡體   English   中英

清除Flipview中的項目時出現System.Exception

[英]System.Exception when clearing items in Flipview

因此,我試圖使用Items.Clear()在活動視圖中清除我的項目。 但是當嘗試清除項目時,錯誤始終顯示“ System.Exception ”。 這是我的代碼:

        openPicker.FileTypeFilter.Clear();
        openPicker.FileTypeFilter.Add(".bmp");
        openPicker.FileTypeFilter.Add(".png");
        openPicker.FileTypeFilter.Add(".jpeg");
        openPicker.FileTypeFilter.Add(".jpg");
        var files = await openPicker.PickMultipleFilesAsync();


        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);
              //Some imagedecoder here
               BitmapImage img = new BitmapImage();
                    img.SetSource(outStream);
              }


            }
         flpcakeimages.Items.Clear(); //System.Exception error here it says'Catastrophic error'
         flpCakeImages.ItemsSource = images;

這是更新活動掛圖的正確方法嗎? 我使用了.UpdateLayout但仍無法正常工作,請您能幫我嗎?

您可以更換

flpcakeimages.Items.Clear();

flpCakeImages.ItemsSource = null;

如果您無法替換flipView的內容,請執行以下操作:

flpCakeImages.ItemsSource = oldDataSource;
flpCakeImages.ItemsSource = null;
flpCakeImages.ItemsSource = newDataSource;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM