private UIElement CreateContainer(object item) { var picture = new ProfilePicture(); picture.IsEnabled = false; picture.Width = _itemSize; picture.Height = _itemSize; if (item is MessageSender sender) { RecentUserHeadChanged?.Invoke(picture, sender); } var borderBrush = new Binding(); borderBrush.Source = this; borderBrush.Path = new PropertyPath(nameof(BorderBrush)); var container = new Border(); container.Width = _itemSize + 4; container.Height = _itemSize + 4; container.VerticalAlignment = VerticalAlignment.Top; container.HorizontalAlignment = HorizontalAlignment.Left; container.BorderThickness = new Thickness(2); container.CornerRadius = new CornerRadius((_itemSize + 4) / 2); container.Child = picture; container.Tag = item; container.SetBinding(Border.BorderBrushProperty, borderBrush); return(container); }
private void UpdateContainer(UIElement container, int newIndex) { if (_items.Count > newIndex && container is Border border && border.Child is ProfilePicture picture && border.Tag is MessageSender previous) { if (_items[newIndex] is MessageSender sender && !sender.IsEqual(previous)) { RecentUserHeadChanged?.Invoke(picture, sender); } } }