I have an ObservbleCollection
with binding to listbox. After I put the collection as ItemsSource of the list, I cannot update my collection. If I update it, the program close (without any crash).
The Code:
I have the class:
class MyFile
{
String FileName {get; set;}
ImageSource Ico {get; set;}
}
Then run the code in the constractor (after InitializeComponents)
ObservableCollection<MyFile> filesList = new ObservableCollection<MyFile>();
filesList.Add(new MyFile { Name = "bar.doc", Ico = null } // Work Fine
filesList.Add(new MyFile { Name = "foo.txt", Ico = null } // Work Fine
files.ItemsSource = filesList;
filesList.Add(new MyFile { Name = "try.txt", Ico = null } // EXIT FROM PROGRAM
What's wrong in my program?
Edit
Just tested it with null instead GetIcon
GetIcon
method? - Hossein Narimani Radfiles
? - Shani ElharrarListBox
with templates - nrofis