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


C# ObservableCollection.AddRange方法代码示例

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


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

示例1: SettingsVM

        public SettingsVM()
        {
            TemperatureUnitList = Settings.TemperatureUnits;
            HopFormulaList = Settings.HopFormulas;

            //add both unit lists, the metric and american unit, to the listpicker
            WeightUnitList = new ObservableCollection<string>();
            WeightUnitList.AddRange(Settings.MetricWeightUnits);
            WeightUnitList.AddRange(Settings.USWeightUnits);

            //same here for volume units
            VolumeUnitList = new ObservableCollection<string>();
            VolumeUnitList.AddRange(Settings.MetricVolumeUnits);
            VolumeUnitList.AddRange(Settings.USVolumeUnits);

            //selected items
            this._WeightSelection = Settings.WeightUnit;
            this._VolumeSelection = Settings.VolumeUnit;
            this._TemperatureSelection = Settings.TemperatureUnit;
            this._HopFormulaSelection = Settings.HopFormula;

            RaisePropertyChanged("WeightSelection");
            RaisePropertyChanged("TemperatureSelection");
            RaisePropertyChanged("VolumeSelection");
            RaisePropertyChanged("HopFormula");
        }
开发者ID:hotzenklotz,项目名称:BrewingApp,代码行数:26,代码来源:SettingsVM.cs

示例2: LeagueItemViewModel

        public LeagueItemViewModel(GameCore core)
            : base(core)
        {
            Cities = new ObservableCollection<City>();
            TeamViewModels = new ObservableCollection<TeamViewModel>();
            GenerateRandomTeamsViewModel = new GenerateRandomTeamsViewModel(core);
            Reputation = 200;

            GenerateRandomTeamsTogglePopup = new RelayCommand(() =>
            {
                TogglePopup();
            });

            GenerateRandomTeams = new RelayCommand(() =>
            {
                var teams = GenerateRandomTeamsViewModel.GenerateTeams();

                TeamViewModels.Clear();
                TeamViewModels.AddRange(teams.Select(team => team.ToViewModel(core)));
                TeamViewModels.ForEach(vm => vm.Changed += Changed);

                NotifyPropertyChanged("TeamListViewVisibility");
                NotifyPropertyChanged("GenerateRandomTeamsButtonVisibility");
                TogglePopup();
            });

            Reload(core);
        }
开发者ID:tthordarson,项目名称:FMScoutFramework,代码行数:28,代码来源:LeagueItemViewModel.cs

示例3: CreateBranchWindowVM

        public CreateBranchWindowVM(ControlConstructSchemeVM controlConstructScheme, IfThenElse ifThenElse)
        {
            this.controlConstructScheme = controlConstructScheme;

            questionConstructs = new ObservableCollection<QuestionConstructVM>();
            questionConstructs.AddRange(controlConstructScheme.QuestionConstructs);

            thenConstructs = new ObservableCollection<ConstructVM>();
            thenConstructs.AddRange(controlConstructScheme.ThenConstructs);

            if (ifThenElse == null)
            {
                //新規作成の場合

                TargetQuestionConstruct = controlConstructScheme.SelectedConstruct as QuestionConstructVM;
                branches = new ObservableCollection<BranchVM>();
                //IF~THENを追加
                BranchVM ifBranch = new BranchVM(BranchVM.TYPE_IF_CODE)
                {
                    Parent = this,
                    No = 1,
                };
                ifBranch.Init();
                branches.Add(ifBranch);
            }
            else
            {
                // 編集の場合

                TargetQuestionConstruct = EDOUtils.Find(controlConstructScheme.QuestionConstructs, ifThenElse.IfCondition.QuestionId);
                branches = SequenceUtils.CreateBranches(ifThenElse, this);
            }
        }
开发者ID:Easy-DDI-Organizer,项目名称:EDO,代码行数:33,代码来源:CreateBranchWindowVM.cs

示例4: ShouldAddWrapperItemsInCorrectPositionFromConstructor

        public void ShouldAddWrapperItemsInCorrectPositionFromConstructor()
        {
            var list = new List<string> { "item1", "Clown", "item1", "Zebra", "apple", "item1", "apple" };

            var collectionA = new ObservableCollection<string>();
            collectionA.AddRange(list);

            collectionA[0].ShouldBe("item1");
            collectionA[1].ShouldBe("Clown");
            collectionA[2].ShouldBe("item1");
            collectionA[3].ShouldBe("Zebra");
            collectionA[4].ShouldBe("apple");
            collectionA[5].ShouldBe("item1");
            collectionA[6].ShouldBe("apple");

            var wrapper = new ObservableCollectionWrapper<string, StringWrapper>(collectionA, item => new StringWrapper(item));
            wrapper.Count.ShouldBe(7);

            wrapper[0].Source.ShouldBe(list[0]);
            wrapper[1].Source.ShouldBe(list[1]);
            wrapper[2].Source.ShouldBe(list[2]);
            wrapper[3].Source.ShouldBe(list[3]);
            wrapper[4].Source.ShouldBe(list[4]);
            wrapper[5].Source.ShouldBe(list[5]);
            wrapper[6].Source.ShouldBe(list[6]);
        }
开发者ID:philcockfield,项目名称:Open.TestHarness.SL,代码行数:26,代码来源:ObservableCollectionWrapperTest.cs

示例5: ReadRecentPackages

		void ReadRecentPackages()
		{
			IReadOnlyList<RecentPackageInfo> savedRecentPackages = properties.GetList<RecentPackageInfo>(RecentPackagesPropertyName);
			
			recentPackages = new ObservableCollection<RecentPackageInfo>();
			recentPackages.AddRange(savedRecentPackages);
			recentPackages.CollectionChanged += RecentPackagesCollectionChanged;
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:8,代码来源:PackageManagementOptions.cs

示例6: AirportsViewModel

        public AirportsViewModel(IGetAirports airportsService, IStoreObjects objectStore)
        {
            _objectStore = objectStore;
            Airports = new ObservableCollection<Airport>();
            Airports.Add(Airport.Nearest);
            Airports.AddRange(airportsService.GetNorwegianAirports());

            SaveCommand = new RelayCommand(OnSave);
            LoadSelectedAirportFromDisk();
        }
开发者ID:chrisntr,项目名称:FlightsNorway,代码行数:10,代码来源:AirportsViewModel.cs

示例7: ApplicationListViewModel

		public ApplicationListViewModel() {
			var remoteServer = Properties.Settings.Default.RemoteAppServer;
			_applicationManager = new IisApplicationManager(remoteServer);
			ApplicationList = new ObservableCollection<ApplicationViewModel>();
			ApplicationQueue = new ObservableCollection<ApplicationViewModel>();
#if DESIGN
			ApplicationList.AddRange(TestUtils.CreateVms(20));
			ApplicationQueue.AddRange(TestUtils.CreateVms(20, new List<AppState> { AppState.Deleting, AppState.ToDelete, AppState.DeleteError }));
#endif
#if ASYNC_TEST
			ApplicationList.AddRange(TestUtils.CreateVms(20));
#endif
			DeleteApplicationCmd = new DelegateCommand<ApplicationViewModel>(DeleteApplication);
			UndoDeleteApplicationCmd = new DelegateCommand<ApplicationViewModel>(UndoDeleteApplication);
			GetDeleteApplicationInfoCmd = new DelegateCommand<ApplicationViewModel>(GetDeleteApplicationInfo);
			BrowseApplicationCmd = new DelegateCommand<ApplicationViewModel>(BrowseApplication);
			ScanApplicationsCmd = DelegateCommand.FromAsyncHandler(ScanApplications);
			InitObservers();
			SubscribeOnApplicationQueue();
		}
开发者ID:vadimart92,项目名称:TeamCityTools,代码行数:20,代码来源:ApplicationListViewModel.cs

示例8: TestSetup

        public void TestSetup()
        {
            item1 = new Model { Name = "1" };
            item2 = new Model { Name = "2" };
            item3 = new Model { Name = "3" };
            item4 = new Model { Name = "4" };
            item5 = new Model { Name = "5" };
            collection = new ObservableCollection<Model>();
            collection.AddRange(item1, item2, item3, item4, item5);

            eventBatcher = new CollectionChangedEventBatch<Model>(collection);
        }
开发者ID:philcockfield,项目名称:Open.TestHarness.SL,代码行数:12,代码来源:CollectionChangedEventBatch.Test.cs

示例9: ShouldAddRange

        public void ShouldAddRange()
        {
            var collection = new ObservableCollection<int>();
            var range = new[] { 1, 2, 3, 4, 5, 6 };
            collection.AddRange(range);
            collection.Count.ShouldBe(6);

            collection = new ObservableCollection<int> { 9 };
            collection.AddRange(range);
            collection[0].ShouldBe(9);
            collection[1].ShouldBe(1);
        }
开发者ID:philcockfield,项目名称:Open.TestHarness.SL,代码行数:12,代码来源:CollectionExtensionsTest.cs

示例10: SearchArena

        public static ObservableCollection<Child> SearchArena()
        {
            var result = new ObservableCollection<Child>();

            EnterToBigArenaResponse response = new EnterToBigArenaService().ExecuteSerialize<EnterToBigArenaResponse>();

            if (response != null && response.success)
            {
                result.AddRange(response.children.Where(x => x.arenaStatus == 1));
            }

            return result;
        }
开发者ID:reekroo,项目名称:HOCb,代码行数:13,代码来源:ArenaController.cs

示例11: SumAggregatorCollectionChangeCausesRefresh

        public void SumAggregatorCollectionChangeCausesRefresh()
        {
            var numbers = new ObservableCollection<object>();
            numbers.AddRange(1, 2, 4);
            var aggregator = numbers.AsBindable<object, int>().Sum();
            var eventCatcher = new PropertyEventMonitor(aggregator);
            Assert.AreEqual(1 + 2 + 4, aggregator.Current);
            Assert.AreEqual(1, eventCatcher.Count);

            // Test an Add
            numbers.Add(8);
            Assert.AreEqual(1 + 2 + 4 + 8, aggregator.Current);
            Assert.AreEqual(2, eventCatcher.Count);

            // Test a Remove
            numbers.RemoveAt(0);
            Assert.AreEqual(2 + 4 + 8, aggregator.Current);
            Assert.AreEqual(3, eventCatcher.Count);

            // Test a Replace
            numbers[0] = 4;
            Assert.AreEqual(4 + 4 + 8, aggregator.Current);
            Assert.AreEqual(4, eventCatcher.Count);

            // Test an AddRange
            numbers.AddRange(4, 5);
            Assert.AreEqual(4 + 4 + 8 + 4 + 5, aggregator.Current);
            Assert.AreEqual(5, eventCatcher.Count);

            // Test a replace with the same value - no events should be raised
            numbers[0] = numbers[0];
            Assert.AreEqual(4 + 4 + 8 + 4 + 5, aggregator.Current);
            Assert.AreEqual(5, eventCatcher.Count);

            // Test an add with 0
            numbers.Add(0);
            Assert.AreEqual(4 + 4 + 8 + 4 + 5, aggregator.Current);
            Assert.AreEqual(5, eventCatcher.Count);
        }
开发者ID:svn2github,项目名称:bindablelinq,代码行数:39,代码来源:SumAggregatorTests.cs

示例12: CreateBranches

 public static ObservableCollection<BranchVM> CreateBranches(IfThenElse ifThenElse, CreateBranchWindowVM window)
 {
     ObservableCollection<BranchVM> branches = new ObservableCollection<BranchVM>();
     BranchVM ifBranch = CreateIfBranch(ifThenElse, window);
     branches.Add(ifBranch);
     List<BranchVM> elseIfBranches = CreateElseIfBranches(ifThenElse, window);
     branches.AddRange(elseIfBranches);
     BranchVM elseBranch = CreateElseBranch(ifThenElse, window);
     if (elseBranch != null)
     {
         branches.Add(elseBranch);
     }
     return branches;
 }
开发者ID:Easy-DDI-Organizer,项目名称:EDO,代码行数:14,代码来源:SequenceUtils.cs

示例13: GenerateAppointments

		private void GenerateAppointments(IDateSpan dateSpan)
		{
			ObservableCollection<Appointment> newSource = new ObservableCollection<Appointment>();

			newSource.AddRange(
				from i in Enumerable.Range(0, (dateSpan.End - dateSpan.Start).Days * 24)
				select new Appointment()
				{
					Subject = "Appointment" + i + " " + dateSpan.Start.AddHours(i).ToShortDateString(),
					Start = dateSpan.Start.AddHours(i),
					End = dateSpan.Start.AddHours(i + 1),
				});

			this.Appointments = newSource;
		}
开发者ID:netintellect,项目名称:PluralsightSpaJumpStartFinal,代码行数:15,代码来源:ViewModel.cs

示例14: AllAvoidAttackMoves

 public static ObservableCollection<Move> AllAvoidAttackMoves()
 {
     ObservableCollection<Piece> attackablePieces = new ObservableCollection<Piece>();
     foreach (Move move in This.Game.OppositePlayer.AllMoves())
     {
         if (move.EndPosition.Piece != null && !attackablePieces.Contains(move.EndPosition.Piece))
             attackablePieces.Add(move.EndPosition.Piece);
     }
     ObservableCollection<Move> possible = new ObservableCollection<Move>();
     foreach (Piece piece in attackablePieces)
     {
         possible.AddRange<Move>(piece.LegalMoves);
     }
     return possible;
 }
开发者ID:Puddler,项目名称:Chess,代码行数:15,代码来源:Defense.cs

示例15: CustomerServiceClient_GetOrdersByCriteriaCompleted

 void CustomerServiceClient_GetOrdersByCriteriaCompleted(object sender, GetOrdersByCriteriaCompletedEventArgs e)
 {
     try
     {
         Orders = new ObservableCollection<OrderListDTO>();
         Orders.AddRange(e.Result.Orders);
     }
     catch (Exception)
     {
         
         throw;
     }
     
     this.RaisePropertyChanged(ord=> ord.Orders);
     //InvokePropertyChanged(new PropertyChangedEventArgs("Orders"));
     _isLoaded = true;
 }
开发者ID:ikelos555,项目名称:HSROrderApp,代码行数:17,代码来源:OrderViewModel.cs


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