List box with text and non-text content in the list box items.

image_pdfimage_print


   
  

<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:src="clr-namespace:ListBoxEvent"  
    x:Class="ListBoxEvent.Pane1">


  <StackPanel>
    <DockPanel Margin="10, 10, 3, 3" >
      <ListBox SelectionMode="Multiple">
        <DockPanel>
          <Image Source="datacat.png"/>
          <TextBlock>CAT</TextBlock>
        </DockPanel>
        <DockPanel>
          <Image Source="datadog.png"/>
          <TextBlock>DOG</TextBlock>
        </DockPanel>
        <DockPanel>
          <Image Source="datafish.png"/>
          <TextBlock>FISH</TextBlock>
        </DockPanel>
      </ListBox>
    </DockPanel>
  </StackPanel>

</Canvas>
//File:Window.xaml.cs

using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Data;
using System.Windows.Media;
using System.Collections.ObjectModel;

namespace ListBoxEvent
{

    public partial class Pane1 : Canvas
    {

        public Pane1() : base()
        {
            InitializeComponent();
        }
    }

}