When you created a DependencyProperty
,
DependencyProperty.Register(
"YearPublished",
typeof(int),
typeof(SimpleControl),
new PropertyMetadata(2000));
based on the YearPublished property, you are basically registering it with the DependencyProperty framework in a way that every time the property is read from or written to, it notifies all subscribers of the event that has taken place. You register it by specifying the name of the property i.e. "YearPublished"
, the property type, the type of the control where the property resides and, in this case the initial value of 2000
.
By binding it to the TextBlock
,
<TextBlock Text="{Binding YearPublished, ElementName=_simple}" />
you are letting the text block know when the property changes so it can update itself. When the YearPublished
property changes, it notifies the text block of this change, which in turn retrieves the updated value and updates its Text
property with it.
This is a very high level view, though, but enough to use it properly. To further understand the internals take a look at this MSDN post.