/// <summary>
 /// Deletes the car data from isolated storage and resets the Car property.
 /// </summary>
 public static void DeleteCar()
 {
     appSettings.Remove(CAR_KEY);
     appSettings.Save();
     Car = null;
     DeleteCarPhoto();
     DeleteTempCarPhoto();
     NotifyCarUpdated();
 }
        /// <summary>
        /// Initializes the view and its data context. 
        /// </summary>
        private void InitializePageState()
        {
            // Retrieve data from temporary storage if present; 
            // otherwise, copy data from CarDataStore.Car.
            if (State.ContainsKey(CAR_INFO_KEY))
            {
                _car = (Car)State[CAR_INFO_KEY];

                // Restore the read-only state of the odometer text box.
                OdometerTextBox.IsReadOnly = (bool)State[ODOMETER_READONLY_STATE];

                // Restore the change state except when the PhotoTask_Completed 
                // method has already set the change state.
                if (!_hasUnsavedChanges) _hasUnsavedChanges =
                    (bool)State[HAS_UNSAVED_CHANGES_KEY];

                // Delete temporary storage to avoid unnecessary storage costs.
                State.Clear();
            }
            else
            {
                _car = CarDataStore.Car;

                // Delete the temporary photo if it exists. This prevents an old
                // temporary photo selection from reappearing after tombstoning.
                CarDataStore.DeleteTempCarPhoto();

                // Disable the odometer text box when displaying a saved value.
                OdometerTextBox.IsReadOnly = _car.InitialOdometerReading > 0;

                // Disable the delete car button for new car
                if (_car.InitialOdometerReading.Equals(0))
                {
                    var deleteButton = (ApplicationBarIconButton)this.ApplicationBar.Buttons[1];
                    deleteButton.IsEnabled = false;
                }
            }

            // Set the page data context to the car.
            DataContext = _car;
        }