Пример #1
0
        public void SetItemTrue(int ID)
        {
            if (Items.Count != 0)
            {
                for (int i = Items.Count - 1; i >= 0; i--)
                {
                    if (Items[i].ID == ID)
                    {
                        PhraseListItemViewModel newItem = Items[i];
                        newItem.IsSelected = true;
                        Items.Remove(Items[i]);
                        Items.Add(newItem);
                        OnPropertyChanged(nameof(Items));

                        SelectedItem = newItem;
                        OnPropertyChanged(nameof(SelectedItem));
                    }
                    else
                    {
                        PhraseListItemViewModel newItem = Items[i];
                        newItem.IsSelected = false;
                        Items.Remove(Items[i]);
                        Items.Add(newItem);
                    }
                }
            }
        }
Пример #2
0
        public void AddPhrase()
        {
            for (int i = Items.Count - 1; i >= 0; i--)
            {
                Items[i].ID = i;
                OnPropertyChanged(nameof(Items));
            }
            PhraseListItemViewModel newItem = new PhraseListItemViewModel
            {
                Abbreviation = "New Phrase",
                Description  = "No Description",
                Content      = "",
                ID           = Items.Count + 1
            };

            Items.Add(newItem);
            WindowViewModel.Instance.ClearSearchText();
            SetItemTrue(newItem.ID);
        }