public Information(User user, Authoriz authoriz) { InitializeComponent(); this.user = user; this.authoriz = authoriz; userName.Text = user.Login; string[] list = JsonTools.DeserializeFromFile <JArray>("namesFile.txt").ToObject <string[]>(); List <string> asd = new List <string>(); var info = authoriz.CheckAccessUsers(user, list); foreach (var item in info) { AccessLevelForUser dic = new AccessLevelForUser(); dic.nameObject = item.Key; dic.nameAccess = item.Value.ToString(); grida.Items.Add(dic); } grida.IsReadOnly = true; allUsers = authoriz.GetDataAllUsers(); ObservableCollection <AllUsersInformation> allUsersInformation1 = new ObservableCollection <AllUsersInformation>(); foreach (var item in allUsers) { AllUsersInformation allUsersInformation = new AllUsersInformation(); allUsersInformation.Login = item.Login; allUsersInformation.SuperUser = item.SuperUser; for (int i = 0; i < info.Count; i++) { switch (i) { case 0: allUsersInformation.ObjectName1 = item.Access.ElementAt(i).Key; allUsersInformation.ObjectAccess1 = item.Access.ElementAt(i).Value.ToString(); break; case 1: allUsersInformation.ObjectName2 = item.Access.ElementAt(i).Key; allUsersInformation.ObjectAccess2 = item.Access.ElementAt(i).Value.ToString(); break; case 2: allUsersInformation.ObjectName3 = item.Access.ElementAt(i).Key; allUsersInformation.ObjectAccess3 = item.Access.ElementAt(i).Value.ToString(); break; default: Console.WriteLine("Default case"); break; } } allUsersInformation1.Add(allUsersInformation); } grida2.ItemsSource = allUsersInformation1; }