Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1050
converter for image list
posted

I have a converter, and class.

How can i display this in xamdatagrid?

 

 private ContactType contactType = ContactType.Contact;
        public Person(ContactType c) {MyContactType = c;}
        public ContactType MyContactType
        {
            get { return contactType; }
            set
            {
                contactType = value;
                OnPropertyChanged("MyContactType");
            }
        }
 

public
class ContactTypeConverter : IValueConverter

{

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)

{

ObservableCollection<Image> contactValues =
new ObservableCollection<Image>();

Person.ContactType contactType = (Person.ContactType)value;

if ((contactType & Person.ContactType.Contact) == Person.ContactType.Contact)

{

contactValues.Add(
new Image { Source = new BitmapImage(new Uri("pack://application:Assets\Contact.jpg")) });

}

if ((contactType & Person.ContactType.Customer) == Person.ContactType.Customer)

{

contactValues.Add(
new Image { Source = new BitmapImage(new Uri("pack://application:Assets\Customer.jpg")) });

}

if ((contactType & Person.ContactType.Manufacturer) == Person.ContactType.Manufacturer)

{

contactValues.Add(
new Image { Source = new BitmapImage(new Uri("pack://application:Assets\Manufacturer.jpg")) });

}

return contactValues;

}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

{

return null;

}