2011-05-30 84 views
1

說我有一個列表框,它的ItemSource勢必類Foo爲itemsource綁定「this」?

集合我如何XAML屬性直接綁定到的Foo實例?

我想綁定的屬性是圖像的來源,並且Foo類有幾個影響源的屬性,所以在我的Converter類中。我想Foo

回答

2

如果你的意思,你必須綁定到集合的ListBoxItemsSource財產(不綁定控件,但它們的屬性),並要顯示在每個Foo圖像收集,你可以這樣做:

<ListBox ItemsSource="{Binding whatever}"> 
    <ListBox.ItemTemplate> 
     <DataTemplate> 
      <Image Source="{Binding Converter={StaticResource converter}}" /> 
     </DataTemplate> 
    </ListBox.ItemTemplate> 
</ListBox> 

只要將綁定的路徑留空,它就設置爲當前項目。

相關問題