-1

I'm trying to bind a WPF combobox to an observable collection of images. Here is my collection:

    public class AvatarPhoto
    {
        public int AvatarId { get; set; }
        public BitmapImage AvatarImage { get; set; }
    }
    public ObservableCollection<AvatarPhoto> AvailableProfilePictures { get; private set; }

Here is my xaml: enter image description here

Visual Studio gives me this compile time error: Property 'ItemTemplate' does not support values of type 'Image'.

Why is this error seen?

Thanks

Update: thanks for the answer! It solved the problem.

Now I have updated my code but I'm seeing this in the ComboBox: enter image description here

Why is it not displaying pictures correctly? In the debug window I can see my collection is correctly populated:

enter image description here

Charlie
  • 764
  • 2
  • 13
  • 24

1 Answers1

9

Put your Image in a DataTemplate:

<ComboBox.ItemTemplate>
    <DataTemplate>
        <Image />
    </DataTemplate>
</ComboBox.ItemTemplate>
LPL
  • 16,827
  • 6
  • 51
  • 95