public void UpdateMessage(MessageViewModel message) { _message = message; var album = message.Content as MessageAlbum; if (album == null) { return; } Children.Clear(); var groupedMessages = album.Layout; if (groupedMessages.Messages.Count == 1) { if (groupedMessages.Messages[0].Content is MessagePhoto) { Children.Add(new PhotoContent(groupedMessages.Messages[0])); } else if (groupedMessages.Messages[0].Content is MessageVideo) { Children.Add(new VideoContent(groupedMessages.Messages[0])); } return; } var positions = groupedMessages.Positions.ToList(); foreach (var pos in positions) { AspectView element = null; if (pos.Key.Content is MessagePhoto) { element = new PhotoContent(pos.Key); } else if (pos.Key.Content is MessageVideo) { element = new VideoContent(pos.Key); } if (element != null) { element.MinWidth = 0; element.MinHeight = 0; element.MaxWidth = MAX_WIDTH; element.MaxHeight = MAX_HEIGHT; element.BorderThickness = new Thickness(0, 0, ITEM_MARGIN, ITEM_MARGIN); element.Tag = pos.Value; Children.Add(element); } } }
protected override void OnApplyTemplate() { LayoutRoot = GetTemplateChild(nameof(LayoutRoot)) as AspectView; Player = GetTemplateChild(nameof(Player)) as AnimationView; Player.FirstFrameRendered += Player_FirstFrameRendered; _templateApplied = true; if (_message != null) { UpdateMessage(_message); } }
protected override void OnApplyTemplate() { Title = GetTemplateChild(nameof(Title)) as TextBlock; Description = GetTemplateChild(nameof(Description)) as TextBlock; Footer = GetTemplateChild(nameof(Footer)) as InvoiceFooter; Photo = GetTemplateChild(nameof(Photo)) as AspectView; Texture = GetTemplateChild(nameof(Texture)) as Image; _templateApplied = true; if (_message != null) { UpdateMessage(_message); } }
protected override void OnApplyTemplate() { LayoutRoot = GetTemplateChild(nameof(LayoutRoot)) as AspectView; Texture = GetTemplateChild(nameof(Texture)) as Image; Button = GetTemplateChild(nameof(Button)) as FileButton; Player = GetTemplateChild(nameof(Player)) as AnimationView; Overlay = GetTemplateChild(nameof(Overlay)) as Border; Subtitle = GetTemplateChild(nameof(Subtitle)) as TextBlock; Button.Click += Button_Click; _templateApplied = true; if (_message != null) { UpdateMessage(_message); } }