Ejemplo n.º 1
0
        /// <summary>
        /// Активирует модель представления.
        /// </summary>
        public override async void Activate(NavigationMode mode = NavigationMode.New)
        {
            Messages = new MessagesCollection(ContentState.Loading);
            RaisePropertyChanged(() => Messages);

            IDialog dialog = null;

            try
            {
                dialog = await ServiceLocator.Current.GetInstance <IMessagesCacheService>()
                         .GetConversation((long)UserID) as IDialog;
            }
            catch (Exception) { }

            if (dialog == null)
            {
                try
                {
                    dialog = await ServiceLocator.Current.GetInstance <IConversationsService>()
                             .GetDialog(UserID);
                }
                catch (Exception ex)
                {
                    Messages             = new MessagesCollection(ContentState.Error);
                    Messages.LoadCommand = new RelayCommand(() => Activate());

                    RaisePropertyChanged(() => Messages);
                    SendMessageCommand.RaiseCanExecuteChanged();

                    throw ex;
                }
            }

            Conversation = dialog;
            Messages     = dialog.Messages;
            RaisePropertyChanged(() => Messages);
            SendMessageCommand.RaiseCanExecuteChanged();
        }
Ejemplo n.º 2
0
 void Message_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     SendMessageCommand.RaiseCanExecuteChanged();
 }