Derefrencing the carousel itemsource

4 posts, 1 answers
  1. Suhas
    Suhas avatar
    2 posts
    Member since:
    Jun 2012

    Posted 24 Jul 2012 Link to this post

    I have folder full of pngs. I add all the pngs to the the carousel and then after viewing those in Carousel, I need to delete those from my hard disk. But it gives me an error saying the files are still used by the carousel. How do delete the image source??
  2. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 24 Jul 2012 Link to this post

    Hello Suhas,

    You can clear the source of the carousel and remove the images after that.  

    Kind regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Suhas
    Suhas avatar
    2 posts
    Member since:
    Jun 2012

    Posted 24 Jul 2012 Link to this post

    MyCarousel.BeginInit();
                foreach (string png in Directory.GetFiles(output))
                {
                    Image myimage = new Image();
                    var uri = new Uri(png);
                    myimage.Source = new BitmapImage(uri);
                    myimage.Height = 200;
                    myimage.Width = 200;
                    myImages.Add(myimage);
                    
                }          
                MyCarousel.ItemsSource = myImages;
                MyCarousel.EndInit();
    
    To release the files used in carousel, I am doing following
    
    MyCarousel.ItemSource = null;
    MyCarousel.Items.Clear();
    GC.Collect();
    
    but still when I delete the pngs in a output folder, I get an exception saying pngs are being used by another process 
    which is this RadCarousel. 
    
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 25 Jul 2012 Link to this post

    Hello Suhas,

    Could you take a look at this forum thread and follow the ideas illustrated in the threads mentioned there ? Do you still get the same exception ? 

    All the best,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top