Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In most scenarios it does not matter. Lets look at the options</p> <ul> <li>Calculate each time. So here you are consuming CPU each time the UI request the value. But considering how much CPU it takes each time the UI would need to be requesting the value 100s per second before your would even notice a hit. I doubt your UI would require this.</li> <li>Store the value. Here you are consuming memory. Again this is a non issue unless you store many large objects.</li> </ul> <p>So I guess it comes down to what ever is more readable for you. I prefer "Calculating each time". Then using this <a href="http://code.google.com/p/notifypropertyweaver/" rel="nofollow">http://code.google.com/p/notifypropertyweaver/</a> it allows me to write this code</p> <pre><code>public class NotifyingClass1 : INotifyPropertyChanged { public object HoldingObject { get; set; } public bool IsHoldingObject { get { return HoldingObject == null; } } public event PropertyChangedEventHandler PropertyChanged; } </code></pre> <p>And have this compiled to the assembly (ie the dependency is derived)</p> <pre><code>public class NotifyingClass1 : INotifyPropertyChanged { private object holdingObject; public event PropertyChangedEventHandler PropertyChanged; public virtual void OnPropertyChanged(string propertyName) { var propertyChanged = PropertyChanged; if (propertyChanged != null) { propertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } public object HoldingObject { get { return holdingObject; } set { if (holdingObject !=value) { holdingObject = value; OnPropertyChanged("HoldingObject"); OnPropertyChanged("IsHoldingObject"); } } } public bool IsHoldingObject { get { return (HoldingObject == null); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload