Woking with IList<string>

Oct 3, 2010 at 2:10 AM

Hi again, I'm having some troubles with a property of one of my objects, it's a IList<string> which holds a list of images file paths, and I'm trying to use this control to add images to that list. I wrapped the object in a ViewModel using that wrapper as SelectedObject of the PropertyEditor, here a portion of its code:

        [FilePath("Image files (*.jpg)|*.jpg|(*.png)|*.png|(*.bmp)|*.bmp|All files (*.*)|*.*", ".jpg"), DisplayName("Add image")]
        public string AddImage
        {  get {return null;}  
            set
            {
                if (!model.Images.Contains(value))
                {
                    this.model.Images.Add(value);
                    RaisePropertyChanged("Images");
                }
            }
        }

        [DisplayName("Image list")]
        public IList<string> ImageList
        {
            get { return this.model.Images; }
        }

The idea is use the AddImage property to select a file and add it to the collection and show (at first) the list of filenames associated with my object.

Is there (or are planning in) a way to do something like that?

I was thinking that the FilePicker would give the filename insted of holding it in one of its properties? How can I reach it to get the file name? [actually, that is my biggest problem here] and in the other hand... is there an attribute to the properties that I could use to display the list in the same PropertyEditor? the filenames only should be fine, I don't need by now to see the actual images.

Thanks again for this control and your support!

Nachitous.

Coordinator
Oct 4, 2010 at 10:31 PM

Hi! There was a bug in the FilePicker control (used TemplateBinding and it wasn't two way binding), should be corrected now. Get the latest revision and please try again. Your AddImage setter should be called now.

That was creative usage of the property editor :) It would be fun to add it as an example if it works well! You could also consider creating a custom template for the ImageList - with support for both adding and removing items...