Reputation: 7336
private MyObject _myObject;
public MyObject MyObject
{
get { return _myObject; }
set
{
if (_myObject != value)
{
_myObject = value;
RaisePropertyChanged(() => MyObject);
}
}
}
<TextBox Text="{Binding MyObject.MyObjectProperty}"/>
When starting my app, MyObject is initialized, the MyObjectProperty is shown in my TextBox, but when I change the MyObjectProperty of MyObject, the TextBox is not updated!
Upvotes: 0
Views: 369
Reputation: 37224
In addition to what blindmeis said, make sure you also specify two way binding on the textbox.
<TextBox Text="{Binding Path=MyObject.MyProperty, Mode=TwoWay"}/>
Upvotes: 0
Reputation: 22445
does your MyObject object implement INotifyPropertyChanged and call it?
public class MyObject
{
private string _prop;
public string MyObjectProperty
{
get { return _prop; }
set
{
if (_prop!= value)
{
_prop = value;
RaisePropertyChanged(() => MyObjectProperty);
}
}
}
}
and the default UpdateSourceTrigger is LostFocus so you have to leave the textbox to see anything
Upvotes: 1