0

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=. ?

Kraenys
  • 297
  • 1
  • 5
  • 19
  • Have you seen [this SO post](http://stackoverflow.com/questions/5488014/are-binding-path-and-binding-really-equal)? In short, `{Binding Path=.}` is binding to source itself, for example you use it in cases when you don't want to bind to specific property on your datasource, but rather to datasource itself. Might worth to be checking [this blog post](http://www.scottlogic.com/blog/2012/04/20/everything-you-wanted-to-know-about-databinding-in-wpf-silverlight-and-wp7-part-two.html) – Michael Sep 02 '14 at 13:42
  • @michaelmoore The two-way binding is very interesting. I'll have to master this. – Kraenys Sep 03 '14 at 07:08

2 Answers2

1

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.

pushpraj
  • 13,458
  • 3
  • 33
  • 50
1

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

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

Diego
  • 666
  • 1
  • 8
  • 27