Esempio n. 1
0
 private void SubscribeChatsChanged()
 {
     _chatModels.CollectionChanged += ((sender, e) =>
     {
         if (e.OldItems != null)
         {
             foreach (ChatModel it in e.OldItems)
             {
                 Chats.RemoveAt(Chats.FindIndex(x => x.ChatModel == it));
             }
         }
         if (e.NewItems != null)
         {
             foreach (ChatModel it in e.NewItems)
             {
                 int i = 0;
                 for (; i < Chats.Count; i++)
                 {
                     if (Chats[i].ChatModel.Id > it.Id)
                     {
                         break;
                     }
                 }
                 var mb = new ChatLineViewModel(_manager)
                 {
                     ChatModel = it
                 };
                 Chats.Insert(i, mb);
             }
         }
     });
 }
Esempio n. 2
0
 private void InitChats()
 {
     foreach (var model in _chatModels)
     {
         var view = new ChatLineViewModel(_manager)
         {
             ChatModel = model
         };
         Chats.Add(view);
     }
 }