problem with binding a textBox
hi,
i'm trying to bind a simple textbox to a message string returned from object.
first i have a base class -
public class BaseClass : INotifyPropertyChanged
{
private string message
public string Message
{ get {return message;}
set
{ message = value;
OnPropertyChaned("Message");
}
}
public event PropertyChangedEventHandler propertyChanged;
private void OnPropertyChanged(string propertyName)
{
if(propertyChanged!=null)
propertyChanged(this, new PropertyChanedEventArgs(propertyName));
}
}
Also, i have a sub-class -
public Class SubClass : BaseClass
{
}
my viewModel class -
public class ViewModel
{
private BaseClass theClass;
public ViewModel()
{
base=new BaseClass();
}
public BaseClass TheClass
{
get{ return theClass;}
set{ theClass= value;}
}
private void someBtnClickMethod()
{
TheClass = new SubClass();
theClass.Message="123";
}
}
i'm binding the textBox with -
<TextBox Text="{Binding TheClass.Message, UpdateSourceTrigger=PropertyChaned}">
the problem is that when someBtnClickMethod function call than i have to change the object and then binding not working for me, message is not updated in textBox.
what's the problem? how can i fix that?
thanks in advanced.