DataContext
By default, the DataContext
property of all controls is set to the ViewModel itself. You can set a different DataContext
to any control and it will also be applied to all children of the control.
As you can see, the data-binding expression references the FirstName
property which can be found in the Profile
object, not in the ViewModel itself.
<div DataContext="{value: Profile}">
<dot:TextBox Text="{value: FirstName}"/>
</div>
Tasks
- Value-bind the
DataContext
property of the<div>
element to theProfile
property of the ViewModel. - Modify the binding expressions inside the
<div>
element to respect their newDataContext
.
Message | Line | Column | |
---|---|---|---|