private void AddAccount() { AddAccountV addAccountV = new AddAccountV(); if (addAccountV.ShowDialog() == true) { if (addAccountV.DataContext != null && (addAccountV.DataContext is AddAccountVM) && (addAccountV.DataContext as AddAccountVM).Account != null) { Account newAccount = (addAccountV.DataContext as AddAccountVM).Account; AccountsList.Add(newAccount); AccountsList = AccountsList.OrderBy(x => x.Server).ThenBy(x => x.CustomName).ThenBy(x => x.Login).ToList(); } } }