Пример #1
0
        protected void ChangeItemState(object param, CommunicationItemState state, bool isEditing)
        {
            if (param is CommunicationItemViewModel)
            {
                // if old state is  Appended we have no to change it
                if ((param as CommunicationItemViewModel).State == CommunicationItemState.Appended)
                {
                    //if old state is  Appended and new state Deleted then delete item
                    if (state == CommunicationItemState.Deleted)
                    {
                        Items.Remove((param as CommunicationItemViewModel));
                    }
                }
                else
                {
                    (param as CommunicationItemViewModel).State = state;
                }

                (param as CommunicationItemViewModel).IsEditing = isEditing;
                (param as CommunicationItemViewModel).RaiseCanExecuteChanged();

                if (state == CommunicationItemState.Deleted)
                {
                    RefreshItems();
                }
                if (isEditing)
                {
                    ItemsCollection.MoveCurrentTo(param as CommunicationItemViewModel);
                }

                OnPropertyChanged("OneItemInCommunicationIsInEditState");
            }
        }