Pregunta

I want to make a ListView that has small images, that was taken from a scanner, inside of the ListView. (I have the scanning script done, and it saves the scanned image under C:/Temp/*.jpg. )

What I'm having trouble with is, I want the scanned images to be displayed inside of the ListView and when you click an image in the ListView it displayed the full Image in the PictureBox.

An Image of what i'm talking about.(tried to post the image inside of this post but rep isn't high enough)

I was thinking about having the images' location stored inside of an List array like

List<string> fileLocationArray = new List<string>();
foreach () {
...
string fileLoc = (@"C:\temp\" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".jpeg");
fileLocationArray.Add(fileLoc);
...
}

Then displaying the images inside the ListView using the List array.

Keep in mind that I plan on uploading these images to an FTP server. That's why I wanted to use a List array.

one more thing, they will be picture of document, not photos, if that means anything to you.

¿Fue útil?

Solución

**Fill ListView :**   
 For(int i=0; i<fileLocationArray.Count();i++)
    {
    System.Windows.Controls.Image imgControl=new System.Windows.Controls.Image();
    BitmapImage imgsrc = new BitmapImage();
   imgsrc.BeginInit();
   imgsrc.UriSource=fileLocationArray[i];
                    imgsrc.EndInit();
    imgControl.source=imgsrc;
    listView.Items.Add(imgControl);

    }

    **After filling ListView control  create event  listView SelectionChanged**
    **imgContolShow   // this control show selected image**

    void listw_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
           imgContolShow.Source = ((System.Windows.Controls.Image)listwiev.SelectedItem).Source;  
        }
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top