void AddItem(ChatItem item) { bool gotoEnd = ScrollBar.VerticalOffset == ScrollBar.ScrollableHeight; if (gotoEnd) { while (Messages.Count >= 250) { Messages.RemoveAt(0); } } Messages.Add(item); if (gotoEnd) { ScrollBar.ScrollToEnd(); } }
void AddItem(ChatItem item) { bool gotoEnd = ScrollBar.VerticalOffset == ScrollBar.ScrollableHeight; while (Messages.Count >= 250) Messages.RemoveAt(0); Messages.Add(item); if (gotoEnd) ScrollBar.ScrollToEnd(); }