Exemplo n.º 1
0
 public void ChangeSource(string searchText = null)
 {
     if (!string.IsNullOrWhiteSpace(searchText))
     {
         var searchItem = MenuItems.Where(s => s.SourceId == -1).First();
         searchItem.SearchPhrase = searchText;
         if (SelectedSource == searchItem)
         {
             MasterDetailViewModel.ChangeSource(SelectedSource);
         }
         else
         {
             SelectedSource = searchItem;
         }
     }
 }
Exemplo n.º 2
0
        public void UpdateViewModel()
        {
            SelectedSource = MenuItems.Where(s => s.SourceId == 1).FirstOrDefault();

            var items = MenuItems.Where(item => item.SourceId > 1).ToList();

            foreach (var item in items)
            {
                MenuItems.Remove(item);
            }

            foreach (var source in Source.AllSources)
            {
                var sourceVm = new SourceViewModel(source);
                if (sourceVm.IsEnable)
                {
                    MenuItems.Add(sourceVm);
                }
            }
        }
Exemplo n.º 3
0
        private void InitViewModel()
        {
            MenuItems = new ObservableCollection<SourceViewModel>
            {
                new SourceViewModel(new Source {SourceName = "Поиск", SourceId = -1}),
                new SourceViewModel(new Source { SourceName = "Лента", SourceId = 1 })
            };

            foreach (var source in Source.AllSources)
            {
                var sourceVm = new SourceViewModel(source);
                if (sourceVm.IsEnable)
                {
                    MenuItems.Add(sourceVm);
                }
            }
            SelectedSource = MenuItems.Where(s => s.SourceId == 1).FirstOrDefault();
        }