void setAttachments(MultipleAttachmentsInfo attachments) { if (attachments != null && attachments.LinkUrls != null && attachments.DisplayTextValues != null) { int count = Math.Max(attachments.LinkUrls.Count(), attachments.DisplayTextValues.Count()); if (Attachments == null) Attachments = new ObservableCollection<AttachmentInfo>(); else Attachments.Clear(); for (int i = 0; i < count; i++) { string url = attachments.LinkUrls.ElementAtOrDefault(i); string name = attachments.DisplayTextValues.ElementAtOrDefault(i); Attachments.Add(new AttachmentInfo(){ Name = name, Url = url}); } } }
private static void buildAttachmentsPanel(StackPanel attachmentsStackPanel, MultipleAttachmentsInfo attachments) { if (attachments != null && attachments.LinkUrls != null && attachments.DisplayTextValues != null) { int count = Math.Max(attachments.LinkUrls.Count(), attachments.DisplayTextValues.Count()); for (int i = 0; i < count; i++) { string linkUrl = attachments.LinkUrls.ElementAtOrDefault(i); string link = attachments.DisplayTextValues.ElementAtOrDefault(i); attachmentsStackPanel.Children.Add(createHyperlinkButton(linkUrl, link)); } } }