Control.DataContextproperty describes where controls will look by default for values when binding. The data context will usually be set for top-level controls such as
Windowand child controls will inherit this data context.
MainWindowis created, a new instance of
MainWindowViewModelwill be created and assigned to the window's
DataContextproperty. From here all bindings will by default bind to properties on this object:
DataContextof the parent control is used as the source of the binding: