开发者

Binding to "this" for itemsource?

Say I have a listbox, whose itemsource is bound to a Collection of classes Foo

How can I xaml bind a property directly to t开发者_如何学编程he instance of Foo?

The property I want to bind is the source of an Image, and the Foo class has several properties that influence the source, so in my Converter class. I want Foo


If you mean that you have the ItemsSource property of an ListBox bound to the collection (you don't bind to controls, but to their properties), and you want to show an image for each Foo in the collection, you can do it like this:

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

Just by leaving the binding's path empty, it is set to the current item.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜