public TestListOfMessages(MainClient session, TestPage currentWorkSpace) { InitializeComponent(); CurrentWorkSpace = currentWorkSpace; Session = session; listOfCachedMessages = session.GetCachedMessages(); var listOfMessages = session.GetMyMails(true); foreach (var message in listOfMessages) { if (listOfCachedMessages != null) { if (message.Id == listOfCachedMessages[0].Id) { break; } else { MessagesPanel.Children.Add(new MessageLayout(message)); } } else { MessagesPanel.Children.Add(new MessageLayout(message)); } } if (listOfCachedMessages != null) { foreach (var message in listOfCachedMessages) { MessagesPanel.Children.Add(new MessageLayout(message)); } } }