Ben Adelson
Ben Adelson

Reputation: 43

Use DataContext for the Path attribute of <Binding>

Is it possible to pass the current DataContext as a parameter to a MultiBinding?

<Checkbox.IsEnabled>
    <MultiBinding Converter={...}>
        <Binding Path="SomeProperty" Mode="TwoWay"/>
        <Binding Path="DataContext?" Mode="OneWay"/>
    </MultiBinding>
<Checkbox.IsEnabled>

Upvotes: 2

Views: 238

Answers (1)

Domysee
Domysee

Reputation: 12846

Just use . as Path.

<Binding Path="." Mode="OneWay"/>

Or ignore the Path property alltogether.

<Binding Mode="OneWay"/>

From the Binding.Path documentation:

Optionally, a period (.) path can be used to bind to the current source.

Upvotes: 3

Related Questions