Just use a DataTemplate to display your objects in a ListBox .
Create a data object that contains the row properties and the Image property:
public class Img { public Img(string value, Image img) { Str = value; Image = img; } public string Str { get; set; } public Image Image { get; set; } }
Create a DataTemplate to display this:
<ListBox x:Name="lstBox"> <ListBox.ItemTemplate> <DataTemplate DataType="{x:Type local:Img}"> <StackPanel> <TextBlock Margin="3" Text="{Binding Str}"/> <ContentControl Margin="3" Content="{Binding Image}"/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox>
Now add the Img elements (or your data objects) to the ListBox like this:
lstBox.Items.Add(new Img("Value", myImage));
source share