1
<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>
我在代码隐藏绑定这样的:数据绑定列表框 - 一个对象部件需要特殊处理
DisplayItemListBox.ItemsSource = (List<MyObject>) MyObjectList;
myObject的有,我需要转换为BitmapImage的在后面的代码的二进制照片属性。我需要修改我的XAML,这样当ListBoxItems首次被数据初始化时,一个可以访问ListBoxItem的MyObject和它的MyImage的函数被打中。