public void Bind(TextNode model) { Unbind (); this.model = model; // this.model.PropertyChanged += HandlePropertyChanged; this.handlers = new List<PropertyChangedEventHandler> (); this.handlers.Add(this.labelCaption.Bind (model, "Caption")); this.handlers.Add(this.textText.Bind(model, "Text")); this.model.PropertyChanged += HandlePropertyChanged; this.textText.Enabled = this.model.Enabled; }
public void Unbind() { if (this.handlers != null) { foreach (var handler in this.handlers) { this.model.PropertyChanged -= handler; } } if (this.model != null) { this.model.PropertyChanged -= HandlePropertyChanged; } this.model = null; }