当前位置: 首页>>代码示例>>C#>>正文


C# ObservableCollection.IndexOf方法代码示例

本文整理汇总了C#中ObservableCollection.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.IndexOf方法的具体用法?C# ObservableCollection.IndexOf怎么用?C# ObservableCollection.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObservableCollection的用法示例。


在下文中一共展示了ObservableCollection.IndexOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateCollectionItem

 public static void UpdateCollectionItem(ObservableCollection<string> collection,
     string item,
     string newValue)
 {
     if (collection != null)
         GUIDispatcher.Invoke((Action)(() => { collection[collection.IndexOf(item)] = newValue; }));
 }
开发者ID:philspain,项目名称:ordoFile,代码行数:7,代码来源:GUIDispatcherUpdates.cs

示例2: Init

        private void Init()
        {
            Musicses = new ObservableCollection<Musics>(Respostory.GetAllMusic());
            InsertMusic = new RelayCommand(() =>
            {
                if (!Musicses.Contains(SelectMusic))
                {
                    Musicses.Insert(0, SelectMusic);
                    Respostory.InsertMusic(SelectMusic);
                }
            });


            LastMusic=new RelayCommand(() =>
                {
                    _incuten = Musicses.IndexOf(SelectMusic);
                    if (-1 != _incuten)
                    {
                        SelectMusic = Musicses[_incuten - 1 >= 0 ? _incuten - 1 : 0];
                    }
                });

            NextMusic = new RelayCommand(() =>
                {
                    _incuten = Musicses.IndexOf(SelectMusic);
                    if (-1 != _incuten)
                    {
                        SelectMusic = Musicses[_incuten + 1 < Musicses.Count ? _incuten + 1 : Musicses.Count-1];
                    }
                });
        }
开发者ID:SeptemberWind,项目名称:AlarmClock-WPF,代码行数:31,代码来源:MusicPlayerViewModel.cs

示例3: setNewParent

        public static void setNewParent(Guid itemId, Guid parentId, ObservableCollection<Todo> _Todos)
        {
            var thisItm = _Todos.FirstOrDefault(x=>x.Id==itemId);

            if (parentId!= Guid.Empty)
            {
                var prnt = _Todos.FirstOrDefault(x => x.Id == parentId);
                thisItm.ParentId = prnt.Id;
                thisItm.Wbs = prnt.Wbs + ">";
                int newIdx = _Todos.IndexOf(prnt)+1;
                if (newIdx <= _Todos.Count)
                {
                    _Todos.Remove(thisItm);
                    _Todos.Insert(newIdx, thisItm);
                }
                else
                {
                    _Todos.Remove(thisItm);
                    _Todos.Add(thisItm);
                }
            }
            else
            {
                thisItm.ParentId = Guid.Empty;
                thisItm.Wbs = ">";
            }

            //_Todos[itemIndex] = thisItm;
            updateChildren(thisItm, _Todos);
        }
开发者ID:amitthk,项目名称:wpftdm,代码行数:30,代码来源:MainWindowUIHelper.cs

示例4: SettingsViewModel

        public SettingsViewModel(IShell shell, ISettingsService settingsService, ICacheService cacheService, IBoard board, INewsService newsService) {
            Shell = shell;
            Board = board;
            SettingsService = settingsService;
            CacheService = cacheService;
            AvailableLanguages = new ObservableCollection<CultureInfo>(
                new[] { "en-US", "ru" }.Select(l => new CultureInfo(l)));
            CurrentLanguage = CultureInfo.CurrentUICulture;
            currentLanguageIndex = AvailableLanguages.IndexOf(CurrentLanguage);
            Application.Current.Suspending += ApplyLanguage;

            FontScale = SettingsService.FontScale;

            AvailableThemes = new ObservableCollection<Theme>(Utils.GetEnumValues<Theme>());
            CurrentThemeIndex = AvailableThemes.IndexOf(SettingsService.CurrentTheme);

            AvailableRepliesDisplayModes =
                new ObservableCollection<RepliesDisplayMode>(Utils.GetEnumValues<RepliesDisplayMode>());

            Version = CreateVersion();
            IsRedstoneBuild = Utils.IsRedstone();

            SetupMediaDownloadFolder();

            AvailableDomains = new ObservableCollection<string>(board.UrlService.AvailableDomains);
            CurrentDomainIndex = SettingsService.CurrentDomain == "" ? 0 : AvailableDomains.IndexOf(SettingsService.CurrentDomain);

            NewsService = newsService;
        }
开发者ID:acedened,项目名称:TheChan,代码行数:29,代码来源:SettingsViewModel.cs

示例5: PhotoDetailViewModel

 public PhotoDetailViewModel(ObservableCollection<PhotoContainerViewModel> photoViewModelList, PhotoContainerViewModel currentPhotoContainerViewModel)
     : this()
 {
     _PhotoViewModelList = photoViewModelList;
     CurrentIndex = photoViewModelList.IndexOf(currentPhotoContainerViewModel);
     this.OnPropertyChanged(() => this.CurrentImage);
 }
开发者ID:radiantwf,项目名称:Face-PhotoAlbum,代码行数:7,代码来源:PhotoDetailViewModel.cs

示例6: InitLoad

		async public Task InitLoad()
		{

			List<lo_by_circle> los_in_Circle = JsonConvert.DeserializeObject<List<lo_by_circle>>(_serialized_list);

			LOsInCircle = new ObservableCollection<lo_by_circle_wrapper>();


			int i = 0;
			foreach (var item in los_in_Circle)
			{

				LOsInCircle.Add(new lo_by_circle_wrapper { lo = item,stack =new stack_wrapper { IsLoaded = false }  });


				//Load images if its the selected LO
				bool images = item.id == LOID;

				//await LoadPages(i++, images);

				await LoadPages2 (i++, images);
			}



			var selectedLOIndex = LOsInCircle.IndexOf(LOsInCircle.Where(lo => lo.lo.id == LOID).First());

			await LoadBackgroundImages();
		}
开发者ID:Milton761,项目名称:MLRepo,代码行数:29,代码来源:LOViewModel.cs

示例7: ClassChanged

        private static void ClassChanged(object sender, NotifyCollectionChangedEventArgs args)
        {
            switch (args.Action) {
                case NotifyCollectionChangedAction.Move:
                    M.ElementIndexChange((Class) sender, (Student) args.OldItems[0], args.OldStartingIndex);
                    Cache = new ObservableCollection<Student>((Class)sender);
                    break;
                case NotifyCollectionChangedAction.Add:
                case NotifyCollectionChangedAction.Replace:
                case NotifyCollectionChangedAction.Remove:
                    if (args.OldItems != null) {
                        foreach (var student in args.OldItems.Cast<Student>()) {
                            M.ElementRemove((Class)sender, student, Cache.IndexOf(student));
                            student.PropertyChanging -= StudentChanging;
                        }
                    }

                    if (args.NewItems != null) {
                        foreach (var student in args.NewItems.Cast<Student>()) {
                            M.ElementAdd((Class) sender, student);
                            student.PropertyChanging += StudentChanging;
                        }
                    }

                    Cache = new ObservableCollection<Student>((Class)sender);
                    break;
                default:
                    throw new NotSupportedException();
            }
        }
开发者ID:buunguyen,项目名称:memento,代码行数:30,代码来源:Program.cs

示例8: HandleCollectionChanges

        private void HandleCollectionChanges(Client client, NotifyCollectionChangedEventArgs args, ObservableCollection<Interlocutor> actualCollection, ObservableCollection<object> nullCollection)
        {
            if (actualCollection.Count == 0)
            {
                nullCollection.Clear();
                nullCollection.Add(new NullInterlocutor(client));
                return;
            }
            var nullInterlocutor = nullCollection.OfType<NullInterlocutor>().FirstOrDefault();
            if (nullInterlocutor != null)
            {
                nullCollection.Remove(nullInterlocutor);
            }

            if (args.OldItems != null)
            {
                foreach (var oldItem in args.OldItems)
                {
                    nullCollection.Remove(oldItem);
                }
            }

            if (args.NewItems != null)
            {
                foreach (var newItem in args.NewItems)
                {
                    nullCollection.Insert(actualCollection.IndexOf((Interlocutor) newItem), newItem);
                }
            }
        }
开发者ID:zhongleiyang,项目名称:vstalk,代码行数:30,代码来源:InterlocutorCollectionConverter.cs

示例9: SalesDashboardLeadsViewModel

        public SalesDashboardLeadsViewModel(Command pushTabbedLeadPageCommand, INavigation navigation = null)
            : base(navigation)
        {
            _PushTabbedLeadPageCommand = pushTabbedLeadPageCommand;

            _DataClient = DependencyService.Get<IDataClient>();

            Leads = new ObservableCollection<Account>();

            MessagingCenter.Subscribe<Account>(this, MessagingServiceConstants.SAVE_ACCOUNT, (account) =>
                {
                    var index = Leads.IndexOf(account);
                    if (index >= 0)
                    {
                        Leads[index] = account;
                    }
                    else
                    {
                        Leads.Add(account);
                    }
                    Leads = new ObservableCollection<Account>(Leads.OrderBy(l => l.Company));
                });

            IsInitialized = false;
        }
开发者ID:rrawla,项目名称:app-crm,代码行数:25,代码来源:SalesDashboardLeadsViewModel.cs

示例10: setWbs

        public static void setWbs(ObservableCollection<Todo> items)
        {
            Action<Todo> SetPostion = null;
            SetPostion = parent =>
            {
                //Recursively call the SetChildren method for each child.
                var children = items.Where(x => x.ParentId == parent.Id).ToList();
                for (int tmp = 0; tmp <= children.Count - 1; tmp++)
                {
                    var child = children[tmp];
                    child.Wbs = parent.Wbs + ">";
                    int newIdx = items.IndexOf(parent) + 1;
                    int oldChildIdx = items.IndexOf(child);

                    if (newIdx < items.Count)
                    {
                        items.Remove(child);

                        if (newIdx>oldChildIdx) {
                            newIdx-=1;
                        }

                        items.Insert(newIdx, child);
                    }
                    else if (newIdx==items.Count)
                    {
                        items.Remove(child);
                        items.Add(child);
                    }

                    SetPostion(child);
                }
            };
            //Initialize the hierarchical list to root level items
            var roots = items.Where(x => x.ParentId == Guid.Empty).ToList();
            for (int tmp = 0; tmp <= roots.Count - 1; tmp++)
            {
                var x=roots[tmp];
                x.Wbs = ">";
                SetPostion(x);
            }
            items.OrderBy(x => x.Wbs);
            //return (items);
        }
开发者ID:amitthk,项目名称:wpftdm,代码行数:44,代码来源:MainWindowUIHelper.cs

示例11: setCurrentViewOrder

 private void setCurrentViewOrder(ObservableCollection<int> userOrder, ObservableCollection<int> curOrder)
 {
     var viewColumns = (listView.View as GridView).Columns;
     
     // ユーザー指定のカラム順番に並び替える
     for (var i = 0; i < Count; ++ i)
     {
         var ci = curOrder.IndexOf(userOrder[i]);
         viewColumns.Move(ci, i);
         curOrder.Move(ci, i);       // カラム順番をViewから取得できないためここで追従
     }
 }
开发者ID:cointoss1973,项目名称:playdotnet,代码行数:12,代码来源:MainWindow.xaml.cs

示例12: ReorderListBoxPage

        public ReorderListBoxPage()
        {
            var brushes = new ObservableCollection<SolidColorBrush>(App.DemoColors.Select(c => c.ToCachedBrush()));

              DataContext = brushes;

              AddHandler(
            ReorderListBox.ReorderRequestedEvent,
            new EventHandler<ReorderEventArgs>(
              delegate(object sender, ReorderEventArgs args) {
            var reorderListBox = (ReorderListBox)args.OriginalSource;

            var draggingBrush = (SolidColorBrush)reorderListBox.ItemContainerGenerator.ItemFromContainer(args.ItemContainer);
            var toBrush = (SolidColorBrush)reorderListBox.ItemContainerGenerator.ItemFromContainer(args.ToContainer);

            brushes.Move(brushes.IndexOf(draggingBrush), brushes.IndexOf(toBrush));

              }));

              InitializeComponent();
        }
开发者ID:edealbag,项目名称:bot,代码行数:21,代码来源:ReorderListboxPage.xaml.cs

示例13: ContactsViewModel

      public ContactsViewModel()
      {
        this.Title = "Contacts";
        this.Icon = "list.png";

        dataManager = DependencyService.Get<IDataManager>();
        Contacts = new ObservableCollection<Contact>();

        MessagingCenter.Subscribe<Contact>(this, "SaveContact", (contact) =>
          {
            var index = Contacts.IndexOf(contact);
            if(index >= 0)
              Contacts[index] = contact;
            else
              Contacts.Add(contact);

            Contacts = new ObservableCollection<Contact>(from c in Contacts orderby c.LastName select c);
          });
      }
开发者ID:njmube,项目名称:VervetaCRM,代码行数:19,代码来源:ContactsViewModel.cs

示例14: LeadsViewModel

      public LeadsViewModel()
      {
        this.Title = "Leads";
        this.Icon = "list.png";

        dataManager = DependencyService.Get<IDataManager>();
        Leads = new ObservableCollection<Account>();

          MessagingCenter.Subscribe<Account>(this, "SaveAccount", (account) =>
          {
              var index = Leads.IndexOf(account);
              if (index >= 0)
              {
                  Leads[index] = account;
              }
              else
              {
                  Leads.Add(account);
              }
              Leads = new ObservableCollection<Account>(from l in Leads orderby l.Company select l);
          });

      }
开发者ID:njmube,项目名称:VervetaCRM,代码行数:23,代码来源:LeadsViewModel.cs

示例15: init

        private void init()
        {
            isClosed = true;

            beginedTasks = Task.GetMyBeginedTasks();
            beginedTastsGrid.ItemsSource = beginedTasks;

            allMyTasks = Task.GetTasks(new SQLiteWorker.QueryData
                                           {
                                               Where = "[email protected] and Percents<>@Percents",
                                               Join = "",
                                               Parameters = new List<SQLiteParameter>
                                                                {
                                                                    new SQLiteParameter("GUID",
                                                                                        Settings.CurrentUser.GUID),
                                                                    new SQLiteParameter("Percents", 100)
                                                                }
                                           });
            foreach (Task task in beginedTasks)
            {
                int index = -1;
                foreach (Task allMyTask in allMyTasks)
                {
                    if (allMyTask.GUID == task.GUID)
                    {
                        index = allMyTasks.IndexOf(allMyTask);
                    }
                }

                if (index != -1)
                {
                    allMyTasks.RemoveAt(index);
                }
            }

            allMyTasksGrid.ItemsSource = allMyTasks;
        }
开发者ID:AramisIT,项目名称:AramisTaskManager,代码行数:37,代码来源:BeginTasksWin.xaml.cs


注:本文中的ObservableCollection.IndexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。