From b0154635582d24c96d3b7d9695a87f99afab9290 Mon Sep 17 00:00:00 2001
From: atraczyk <andreastraczyk@gmail.com>
Date: Tue, 6 Sep 2016 12:58:08 -0400
Subject: [PATCH] accounts/UI: prevent deselection of an account

- removes the ability to deselect an account from the account
  listbox

Change-Id: Ie03eee41234727f760e2fb47cb1761e51c8c5af9
Tuleap: #1003
---
 SmartPanel.xaml.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/SmartPanel.xaml.cpp b/SmartPanel.xaml.cpp
index 8ee8d73..2366bec 100644
--- a/SmartPanel.xaml.cpp
+++ b/SmartPanel.xaml.cpp
@@ -180,6 +180,20 @@ void
 SmartPanel::_accountList__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e)
 {
     auto listbox = safe_cast<ListBox^>(sender);
+    // disable deselction from listbox
+    if (listbox->SelectedItem == nullptr)
+    {
+        if (e->RemovedItems->Size > 0)
+        {
+            Object^ itemToReselect = e->RemovedItems->GetAt(0);
+            for each (auto item in listbox->Items) {
+                if (item == itemToReselect) {
+                    listbox->SelectedItem = itemToReselect;
+                    continue;
+                }
+            }
+        }
+    }
     auto account = safe_cast<Account^>(listbox->SelectedItem);
     AccountsViewModel::instance->selectedAccount = account;
     updatePageContent();
-- 
GitLab