private void ProfileActive_Unchecked(object sender, RoutedEventArgs e) { if (!_updatingProfileStatus) { CheckBox checkBox = e.OriginalSource as CheckBox; DisplayContext context = checkBox.DataContext as DisplayContext; Debug.Assert(context != null); // if this is the selected profile then clear the selection if (context.Id == UserSettings.Settings.CurrentContextId) { UserSettings.Settings.CurrentContextId = UserSettings.InvalidContextId; } _currentExpectedAction = ExpectedAction.DeactivateProfile; _clientLogic.AdminDeactivateContext(context.Id); } }