Hi,
I wrote a user control to show some images, and it uses a listbox with uniform grid. The user can add this images dragging a single BitmapSource on a listbox or can initialize the user control (the listbox) with a collection of BitmapSource. Internally, the user control uses a collection of item, and every single item is a custom class <CheckedImage> that group an image, its path, and some other properties for effects etc.
public class CheckedImage : ViewModelBase { public CheckedImage() { } public String ImPath { get; set; } private int _indexImage = -1; public int indexImage { get { return _indexImage; } set { if (value != _indexImage) { _indexImage = value; OnPropertyChanged("indexImage"); } } } private bool _IsEmpty = true; public bool IsEmpty { get { return _IsEmpty; } set { if (value != _IsEmpty) { _IsEmpty = value; OnPropertyChanged("IsEmpty"); } } } private BitmapSource _imageBitmap = EmptyImage; public BitmapSource imageBitmap { get { return _imageBitmap; } set { if (value != _imageBitmap) { _imageBitmap = value; OnPropertyChanged("imageBitmap"); } } } }
The user drags an image on the control and the control creates a <CheckedImage> object with the image and its informations, adding to the collection binded on itemsource of the listbox.
Now, how the user can be read the informations about the single image of the collection showed? The application doesn't know the object class <CheckedImage> in the collection so can't be use for example the BitmapSource property of the item or other one. What's the correct approach to solve the problem?
Thanks.