In this example:
<TextBox Name="textBox1" Height="23" Text="some text" HorizontalAlignment="Left" Margin="69,12,0,0" VerticalAlignment="Top" Width="120" />
<Label Content="{Binding Path=Text, ElementName=textBox1}" Height="28" HorizontalAlignment="Left" Margin="235,12,0,0" Name="label1" VerticalAlignment="Top" />
whatever I type on the textbox will be displayed on the label. I am learning xaml and I believe I understand most of the Bindings such as this one. But I think even though I understand what is happening, it will be nice to understand what the Binding keyword refers to? for example I can have:
<ListView ItemsSource="{Binding}" Name="lv1" />
I am having a hard time understanding what binding actually refers to? There is nothing after the Binding keyword, so what is it binding to? Does it refer to that control? Is it similar to the this keyword used in c# where it will refer to the current instantiated object of a class?
It's not a keyword, it's a markup extension.
Bindings always bind to the Path
relative to the source, if there is no path they bind directly to the source, possible sources are the DataContext
which is used implicitly if no other source is specified and ElementName
, Source
and RelativeSource
. Please read the overview if you have not done so yet.
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