ys, I need help understanding why a field is not being updated: I have two sample class both deriving from Observable that simply implements INotifyPropertyChanged.
public class ClassA : Observable
{
string p1;
public string Property1
{
get { return p1; }
set
{
p1 = value;
RaisePropertyChangedEvent("Property1");
}
}
ClassB p2;
public ClassB Property2
{
get { return p2; }
set
{
if (p2 != null)
p2.PropertyChanged -= OnProperty2Changed;
p2 = value;
if (p2 != null)
p2.PropertyChanged += OnProperty2Changed;
}
}
string p2r;
public string Propert2Representation
{
get { return p2r; }
set
{
p2r = value;
RaisePropertyChangedEvent("Propert2Representation");
}
}
void OnProperty2Changed(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
this.RaisePropertyChangedEvent("Property2");
this.Propert2Representation = Property2.ToString();
}
public override string ToString()
{
return "Class A";
}
}
public class ClassB : Observable
{
public int Property1 { get; set; }
public override string ToString()
{
return "Class B";
}
}
When I change a property in ClassB, the TextBlock bound to Property2 is not updated. However, TextBlock bound to Property2Representation is updated. What am I doing wrong?
TIA.