Possible Duplicate:
WPF Binding Syntax Question
I've been using this syntax all over the place, and I thought I knew what it did, but now I have no idea.
Value="{Binding}"
I am having huge trouble searching for this syntax online because of course the curly brackets are ignored.
For instance:
<Style x:Key="GridCell" TargetType="{x:Type TextBlock}">
<Setter Property="ToolTip" Value="{Binding}}"/>
</Style>
When applied as a style to a textblock is binding the tooltip to the unfomatted (unconverted) property that the textblock content (text) is bound to.
Its data binding value to the root of the window or control's DataContext
.
It binds to the current Datacontext.
I suggest you take a look at the WPF Databinding Cheat Sheet. Should be a handy reference.
The syntax {Binding <something>}
creates a new Binding
using the Binding markup extension.
Specifically, {Binding}
creates the Binding
object with empty path. And since the paths are relative to the current DataContext
, this means binding to it.
The documentation refers to {Binding}
as the "empty binding syntax". It binds the property to the entire object referenced by the DataContext.
It may be worth noting that a control inherits the DataContext of its parent element (unless you set it directly).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With