B
Berryl Hesh
Please tell me how to change the code below to use data binding instead of
manual observer synchronization. My domain model class (Reading) implements
INotifyPropertyChanged
Thanks! - BH
------
public partial class Forms__Controls_AssessmentForm : Form
{
private readonly Reading _model;
public Forms__Controls_AssessmentForm(Reading model) {
InitializeComponent();
_model = model;
txtActual.Validating += new
System.ComponentModel.CancelEventHandler(txtActual_Validating);
_load();
}
void txtActual_Validating(object sender,
System.ComponentModel.CancelEventArgs e) {
_displayVariance();
}
private void _load() {
txtStationId.Text = _model.StationId;
txtDate.Text = _model.Date.ToString();
txtStationId.Text = _model.StationId;
txtTarget.Text = _model.TargetTemperature.ToString();
txtActual.Text = _model.ActualTemperature.ToString();
_displayVariance();
}
private void _displayVariance() {
_model.ActualTemperature = Convert.ToDouble(txtActual.Text);
lblVariance.Text = string.Format("{00}", _model.Variance);
LabelSeverityDisplay.Severity(Reading.DetermineSeverity(_model.Variance),
lblVariance);
}
}
manual observer synchronization. My domain model class (Reading) implements
INotifyPropertyChanged
Thanks! - BH
------
public partial class Forms__Controls_AssessmentForm : Form
{
private readonly Reading _model;
public Forms__Controls_AssessmentForm(Reading model) {
InitializeComponent();
_model = model;
txtActual.Validating += new
System.ComponentModel.CancelEventHandler(txtActual_Validating);
_load();
}
void txtActual_Validating(object sender,
System.ComponentModel.CancelEventArgs e) {
_displayVariance();
}
private void _load() {
txtStationId.Text = _model.StationId;
txtDate.Text = _model.Date.ToString();
txtStationId.Text = _model.StationId;
txtTarget.Text = _model.TargetTemperature.ToString();
txtActual.Text = _model.ActualTemperature.ToString();
_displayVariance();
}
private void _displayVariance() {
_model.ActualTemperature = Convert.ToDouble(txtActual.Text);
lblVariance.Text = string.Format("{00}", _model.Variance);
LabelSeverityDisplay.Severity(Reading.DetermineSeverity(_model.Variance),
lblVariance);
}
}