private async void DisplayPastMessagesAsync(IEnumerable <ChatMessage> messages) { foreach (ChatMessage message in messages) { if (!message.IsOutgoing) { IncomingChatBubble bubble = new IncomingChatBubble(message); bubble.MessageDeleted += bubble_MessageDeleted; bubble.DownloadImage += bubble_DownloadImage; bubble.ImageTapped += Bubble_ImageTapped; bubble.RefreshImage(); MessagesList.Children.Add(bubble); } else { if (!message.IsText && message.FileTransferInformation != null) { var tempFolder = ApplicationData.Current.LocalFolder; string name = message.FileTransferInformation.Name; StorageFile tempFile = await tempFolder.GetFileAsync(name.Substring(0, name.IndexOf('.'))); message.FileTransferFilepath = tempFile.Path; } OutgoingChatBubble bubble = new OutgoingChatBubble(message); bubble.MessageDeleted += bubble_MessageDeleted; bubble.UpdateStatus(message.State); bubble.RefreshImage(); MessagesList.Children.Add(bubble); } } }