Pregunta

So i was trying to clear my items in a flipview using Items.Clear(). but then an error always shows "System.Exception" when trying to clear items. This is my Code:

        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;

Is that a proper way to update the flipview? I used the .UpdateLayout but it still not working, can you guys please help me?

¿Fue útil?

Solución

You can replace

flpcakeimages.Items.Clear();

with

flpCakeImages.ItemsSource = null;

If you cant to replace the contents of flipView, just do like this:

flpCakeImages.ItemsSource = oldDataSource;
flpCakeImages.ItemsSource = null;
flpCakeImages.ItemsSource = newDataSource;
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top