protected bool Set(string propertyName, object value, object defaultValue) { // Setup initial conditions. if (Script.IsNullOrUndefined(value)) value = null; // Don't continue if the value has not changed. object currentValue = Get(propertyName, defaultValue); if (value == currentValue) return false; // Store value and fire event. PropertyBag[propertyName] = value; FirePropertyChanged(propertyName); // Finish up. return true; }