Have read few articles on WPF and I notice that Binding is often used in different ways:
{Binding UserName}
binds to theUserName
property of theUserViewModel
class.{Binding Path=UserName}
same as above.{Binding}
. Notice, it is used by itself, there is no Path or property name provided. I have seen this but don't understand how does this bind to anything?
For example, I have seen this in the article which has a DataTemplate
defining this:
<ContentControl Margin="20,10" Content="{Binding Path=CurrentProduct}" />
, then in MainWindow.xaml
, the Binding
is used like this
<ContentControl Content="{Binding}" HorizontalAlignment="Center" Margin="10" />
Why it is only Binding
by itself used here and what does it mean?