How to display Images in a WPF ListBox

We can put any controls inside a ListBoxItem such as an image or text. To display an image side by side with text, I simply put an Image and TextBlock control within a StackPanel. The Image.Source property takes the name of the image you would like to display in the Image control and TextBlock.Text property takes a string that you would like to display in the TextBlock.

The following code snippet adds an image and text to a ListBoxItem.

<ListBoxItem Background="LightCoral" Foreground="Red"

             FontFamily="Verdana" FontSize="12" FontWeight="Bold">

    <StackPanel Orientation="Horizontal">

        <Image Source="coffie.jpg" Height="30"></Image>

        <TextBlock Text="Coffie"></TextBlock>

    </StackPanel>

</ListBoxItem>