<ListBox Name="DisplayItemListBox">
<ListBox.ItemTemplate>
<DataTemplate>
<ListBoxItem >
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Response}" />
<Button Width="50" Height="50" Content="Remove" Click="Request_Remove_Click"/>
<Image Name="MyImage" Width="50" Height="50" />
</StackPanel>
</ListBoxItem>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I bind in codebehind like this:
DisplayItemListBox.ItemsSource = (List<MyObject>) MyObjectList;
MyObject has a binary Photo attribute that I need to convert to a BitmapImage in code behind. I need to modify my XAML in such a way that, when the ListBoxItems are first initialized with data, a function is hit that has access to both the ListBoxItem’s MyObject and it’s MyImage.
Have you heard of ValueConverters? These allow you to convert a property within the binding process. The following example show how to convert a URI into a BitmapImage which you can use as a Source for an Image element:
http://www.eggheadcafe.com/sample-code/SilverlightWPFandXAML/03d69c15-172b-4098-bb90-5119f9bdac24/silverlight-ivalueconverter-for-image-urls.aspx
You should be able to use something similar.