/// <summary>
        /// Behaviour for when the remove button in the device removal popup is clicked.
        /// </summary>
        private void DeleteDevicePopup_Remove(object sender, EventArgs e)
        {
            // Set delete button state to deleting
            ButtonExtensions.SetDeleting(currentDeleteButton, true);
            var deleteButton = currentDeleteButton;

            // Initiate the async device removal task
            var devices          = new FxA.Devices();
            var removeDeviceTask = devices.RemoveDeviceTask(DeleteDevices.DeviceToDelete.Pubkey, safeRemove: true, silent: true);

            // Check if device removal task was successful
            removeDeviceTask.ContinueWith(task =>
            {
                if (!task.Result)
                {
                    ErrorHandling.ErrorHandler.Handle(new ErrorHandling.UserFacingMessage("toast-remove-device-error"), ErrorHandling.UserFacingErrorType.Toast, ErrorHandling.UserFacingSeverity.ShowError, ErrorHandling.LogLevel.Error);

                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        ButtonExtensions.SetMarkForDeletion(deleteButton, false);
                        ButtonExtensions.SetDeleting(deleteButton, false);
                        EnableDeleteDeviceButton(deleteButton);
                    });
                }
            });

            // If on the device limit reached page, reprocess the login response upon device removal
            if (DeviceLimitReached && !string.IsNullOrEmpty(fxaJson))
            {
                removeDeviceTask.ContinueWith(task =>
                {
                    if (task.Result)
                    {
                        var reprocessLoginResult = Manager.Account.ProcessLogin(fxaJson);
                        if (reprocessLoginResult)
                        {
                            Application.Current.Dispatcher.Invoke(() =>
                            {
                                var owner = Application.Current.MainWindow;
                                if (owner != null)
                                {
                                    ((UI.MainWindow)owner).NavigateToView(new UI.QuickAccessView(), UI.MainWindow.SlideDirection.Left);
                                    ((UI.MainWindow)owner).Activate();
                                }
                            });
                        }
                    }
                });
            }

            // Close the delete device popup
            DeleteDevicePopup_Cancel(sender, e);
        }
        /// <summary>
        /// Behaviour for when the cancel button in the device removal popup is clicked.
        /// </summary>
        private void DeleteDevicePopup_Cancel(object sender, EventArgs e)
        {
            // Cancel device removal flags and re-enable delete button if not currently deleting
            if (currentDeleteButton != null && !ButtonExtensions.GetDeleting(currentDeleteButton))
            {
                ButtonExtensions.SetMarkForDeletion(currentDeleteButton, false);
                EnableDeleteDeviceButton(currentDeleteButton);
                currentDeleteButton = null;
            }

            CloseDeleteDevicePopup();
        }
        /// <summary>
        /// Event handler for when a device list item delete button is clicked.
        /// </summary>
        private void DeleteDevice_Click(object sender, RoutedEventArgs e)
        {
            InitializeDeleteDevicePopup();

            Button deleteDeviceButton = sender as Button;

            Models.DeviceListItem device = deleteDeviceButton.DataContext as Models.DeviceListItem;
            DeleteDevices.DeviceToDelete = device;

            DeleteDevices.PopupTitle   = Manager.TranslationService.GetString("devices-remove-popup-title");
            DeleteDevices.PopupContent = Manager.TranslationService.GetString("devices-remove-popup-content", UI.Resources.Localization.TranslationService.Args("deviceName", device.Name));

            OpenDeleteDevicePopup();

            ButtonExtensions.SetMarkForDeletion(deleteDeviceButton, true);
            DisableDeleteDeviceButton(deleteDeviceButton);
            currentDeleteButton = deleteDeviceButton;
        }