2011-05-19 27 views
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的函數被打中。

回答

相關問題