Kraenys
Kraenys

Reputation: 297

Difference between PATH= and PATH=. on DataBinding

I have just succeeded to use, on c#, the property Binding, I saw two ways to do this: Binding="{Binding Path=DataBinded}" and Binding="{Binding Path=.DataBinded}"

They are both working, but if there is two ways to write, it's for a reason...What's the difference between Path= and Path=. ?

Upvotes: 0

Views: 85

Answers (2)

Diego
Diego

Reputation: 796

Using a period path ("Path=.") will bind to the current source :)

You can read the docs here under remarks seccion (last point)

Upvotes: 1

pushpraj
pushpraj

Reputation: 13679

usually . refers to the preceding object and allow you to point to the sub properties, you may consider it as a separator as well. as mentioned in the question there is no preceding object so in this case the . refers to the DataContext itself and so Binding="{Binding Path=DataBinded}" and Binding="{Binding Path=.DataBinded}" are equal

you may consider the following example when you want to bind some text value directly

<TextBlock Text="{Binding}" />

or

<TextBlock Text="{Binding Path=.}" />

both of the example above points to the DataContext of the TextBlock and will bind to the same.

Upvotes: 1

Related Questions