public ChatMessageView(MeshNetwork network, ChatListItem chatItem) { InitializeComponent(); _network = network; _chatItem = chatItem; this.Title = _network.NetworkName; _network.MessageReceived += network_MessageReceived; _network.MessageDeliveryNotification += network_MessageDeliveryNotification; _network.PeerTyping += network_PeerTyping; if (_network.Type == MeshNetworkType.Private) { _network.OtherPeer.ProfileChanged += otherPeer_ProfileChanged; } //load stored messages int totalMessageCount = _network.GetMessageCount(); if (totalMessageCount > 0) { try { customListView1.ReplaceItems(ConvertToListViewItems(_network.GetLatestMessages(totalMessageCount, MESSAGE_COUNT_PER_SCROLL), true)); customListView1.ScrollToBottom(); } catch { } } }