There is a class ViewModel which implements INPC. There is a public property TextToSend to which the textbox is bind.

 <TextBox Height="120" VerticalAlignment="Top" TextWrapping="Wrap" Margin="5,5,5,5" Text="{Binding TextToSend, Mode=TwoWay}"/> 

Interface implementation:

 class ClientChatModel : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } 

Property to which the binding goes:

  public string TextToSend { get { return _texttosend; } set { _texttosend = value; OnPropertyChanged("TextToSend"); } } private string _texttosend { get; set; } 

It does not issue errors, it does not crash, but if any command is executed that is designed to clear the textbox, i.e. clear the _texttosend to which the Text property of the control is bound; the interface does not receive notifications and the text of the control remains, although the property has already changed. What is my mistake?

  • And how do you clean? Try this: TextToSend = "" - Andrew NOP

1 answer 1

I feel that you are clearing your _texttosend property (why not make it a variable, by the way?) Instead of the TextToSend property.

Try cleaning it like this:

 TextToSend = String.Empty; 
  • I guessed already.) But thanks anyway, they sensed right plus for that! - Sergey