/// <summary> /// Initial Data from Database and sth. else /// </summary> public UserVerifyListViewModel() { if (IsInDesignMode) { return; } var lists = new VerifingFriend().GetVerifingsList();//读取数据库 for (int i = 0; i < lists.Count; i++) { VerifyUserList.Add(lists[i]); } InitialMessanger(); }
/// <summary> /// 添加或更新集合 /// </summary> /// <param name="item">对应的项</param> public void AddOrUpdateToList(VerifingFriend item) { #region 修改集合 if (VerifyUserList.Count(v => v.toUserId == item.toUserId) > 0) { App.Current.Dispatcher.Invoke(() => { var verifyItem = VerifyUserList.FirstOrDefault(v => v.toUserId == item.toUserId); verifyItem.StatusTag = item.StatusTag; verifyItem.VerifyStatus = item.VerifyStatus; }); } else//添加未存在的消息 { App.Current.Dispatcher.Invoke(() => { VerifyUserList.Add(item); }); } #endregion }