Click here to Skip to main content
13,043,092 members (64,879 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I've a listbox that shows some pictures.
this is the xaml code
 <ListBox Height="500" Name="lbThumbnails" IsEnabled="False" SelectionMode="Single" ItemsSource="{Binding Source}" >
                                    <Border BorderBrush="#FFB4B4B4" Opacity="0.7" BorderThickness="2" CornerRadius="5" >
                                        <Image Source="{Binding UriSource}"  Stretch="Fill" Width="100" Height="100" Margin="20"  />

this is the code-behind
pictures = new List<BitmapImage>();
               DirectoryInfo pictureImageDir = new DirectoryInfo("Thumbnails");
               foreach (FileInfo koiImageFile in pictureImageDir.GetFiles("*.jpg"))
                   Uri uri = new Uri(koiImageFile.FullName);
                   pictures.Add(new BitmapImage(uri));
               lbThumbnails.ItemsSource = pictures;
           catch (Exception ex)
               System.Windows.MessageBox.Show("Errore non previsto");

The loading works but after the user click on an item, all the items disappears.
This is the first time that I see this kind of error and i've no idea of what is the problem.
PS: I've tried to manage the selection changed event of listbox, but the execution flow doesn't enter in that code. It's very strange.
Can you help me?

Posted 6-Oct-12 2:47am
Kenneth Haugland 6-Oct-12 9:01am
Very unusual situation consider how you populate your listbox.
Alessio Elia 6-Oct-12 9:13am
Is it the right way for populate the listbox?
Kenneth Haugland 6-Oct-12 9:16am
I won't have done it that way:
Alessio Elia 6-Oct-12 10:04am
I've solved:
When i click on Item the application call the method refreshGallery again.
Sorry for my inattention :(
Jyothikarthik_N 6-Oct-12 18:34pm
Alessio, If the question is resolved - provide the solution under "I've solved it myself" and close it, so it doesn't hang around in the unanswered lot. Thnx!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 6 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100