/// <summary> /// Активирует модель представления. /// </summary> public override async void Activate(NavigationMode mode = NavigationMode.New) { _retriesCount++; var response = await(new GetUsersRequest()).ExecuteAsync(); if (response.Error.ErrorType == VKErrors.None) { Profile = response.Response[0]; _retriesCount = 0; } else if (_retriesCount <= 5) { Activate(); } else { _retriesCount = 0; } }
/// <summary> /// Конструктор по умолчанию. /// </summary> public SidebarViewModel() { #if DEBUG if (IsInDesignModeStatic) { Profile = new VKProfileBase { FirstName = "Роман", LastName = "Гладких", Status = "OneVK design mode." }; MessagesCount = 159; } #endif GoToMessagesView = new RelayCommand(() => NavigationHelper.Navigate(AppViews.MessagesView)); ServiceHelper.VKLongPollService.MessagesCounterChanged += (s, e) => { MessagesCount = e.Count; RaisePropertyChanged("HasNotifications"); }; Messenger.Default.Register <VKAccountGetCountersResponse>(this, OnCountersMessageReceived); }
/// <summary> /// Деактивирует модель представления. /// </summary> public override void Deactivate(NavigationMode mode = NavigationMode.New) { Profile = null; }