Chris McGrath
Chris McGrath

Reputation: 1057

Get Listbox properties from ListBoxItem datatemplate

Is there a way to bind a property of the listboxitem to one of it's owning listbox? I want it in a template so I believe that rules out ElementName.

Upvotes: 1

Views: 147

Answers (1)

Charlie
Charlie

Reputation: 15247

Use the FindAncestor mode of the Binding class. Like this:

{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBox}}, Path=YourProperty}

Upvotes: 3

Related Questions