clx
clx

Reputation: 824

self referencing in data bindings

Let's say there is a Combobox:

<ComboBox ItemsSource="{Path=ListOfItems}">
  <ComboBox.ItemTemplate>
    <DataTemplate>
      <CheckBox Tag="{Binding Path=this}"
        Content="{Binding Path=AProperty}" />
    </DataTemplate>
  </ComboBox.ItemTemplate>                                       
</ComboBox>

Now what I want is that the Content property of ComboBox is bounded to the according list elements's property AProperty (which works fine) and the Tag property is bounded to the list element itself, which does not work. What do I do wrong?

Upvotes: 0

Views: 81

Answers (1)

McGarnagle
McGarnagle

Reputation: 102753

To bind to the current data context you can use .:

<CheckBox Tag="{Binding Path=.}"

Or, effectively the same, simply omit the path altogether:

<CheckBox Tag="{Binding}"

Upvotes: 3

Related Questions