Imagine a Patient
model in WPF where one of the properties are "Temperature". Now one doctor might prefer the temperature in Celsius while another might prefer Fahrenheit. If the temperature property needs to change in UI as the doctor changes preference, I guess the model for Patient would have to subscribe to an event. Something like this:
public Patient()
{
Temperature.Instance.PropertyChanged += TemperatureChanged;
}
~Patient()
{
Temperature.Instance.PropertyChanged -= TemperatureChanged;
}
But while this would work, as you can infer, we are subscribing using a static class inside the Patient
model. Are there some more elegant way of doing this?
Even though the Temperature
class is used in a static context, I'm worried about the models not unsubscribing these events (only solution I know of is in the destructor). And that it might lead to degraded performance as the application runs. Is this concern real?
My only alternative right now, is to require the view to reload when preferences like this changes...