Buu
Buu

Reputation: 50345

Binding to the whole data item in XAML

I'm using XAML data binding for a ListBox whose ItemSource is set to a list of TypeA object. One UI element in the ItemTemplate for the ListBox is bound to a property of TypeA as follows:

Source="{Binding PropertyName, Converter={StaticResource customConverter}}"

Now, instead of binding to a specific property, I want the UI element to be bound to the whole TypeA instance so that the custom converter can compute value from multiple properties. The question is: which binding expression I can use to achieve that?

Upvotes: 6

Views: 1101

Answers (2)

AnthonyWJones
AnthonyWJones

Reputation: 189457

Youn include no path at all to do that:-

 Source="{Binding Converter={StaticResource customConverter}}

Upvotes: 6

TerenceJackson
TerenceJackson

Reputation: 1786

Have you tried this:

Source="{Binding ., Converter={StaticResource customConverter}}"

Upvotes: 6

Related Questions