• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ObservableCollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ConnectControlViewModel_AddNewServer_ResourceRepositoryReturnExistingServers_False

 public void ConnectControlViewModel_AddNewServer_ResourceRepositoryReturnExistingServers_False()
 {
     //------------Setup for test--------------------------
     var mainViewModel = new Mock<IMainViewModel>();
     var connectControlSingleton = new Mock<IConnectControlSingleton>();
     var env1 = new TestEnvironmentModel(new Mock<IEventAggregator>().Object, Guid.NewGuid(), CreateConnection(true, false).Object, new Mock<IResourceRepository>().Object, false);
     var env2 = new TestEnvironmentModel(new Mock<IEventAggregator>().Object, Guid.NewGuid(), CreateConnection(true, false).Object, new Mock<IResourceRepository>().Object, false);
     var connectControlEnvironments = new ObservableCollection<IConnectControlEnvironment>();
     var controEnv1 = new Mock<IConnectControlEnvironment>();
     var controEnv2 = new Mock<IConnectControlEnvironment>();
     controEnv1.Setup(c => c.EnvironmentModel).Returns(env1);
     controEnv2.Setup(c => c.EnvironmentModel).Returns(env2);
     controEnv1.Setup(c => c.IsConnected).Returns(true);
     connectControlEnvironments.Add(controEnv2.Object);
     connectControlEnvironments.Add(controEnv1.Object);
     connectControlSingleton.Setup(c => c.Servers).Returns(connectControlEnvironments);
     var environmentRepository = new Mock<IEnvironmentRepository>();
     ICollection<IEnvironmentModel> environments = new Collection<IEnvironmentModel>
         {
             env1
         };
     environmentRepository.Setup(e => e.All()).Returns(environments);
     var viewModel = new ConnectControlViewModel(mainViewModel.Object, environmentRepository.Object, e => { }, connectControlSingleton.Object, "TEST : ", false);
     //------------Execution-------------------------------
     int serverIndex;
     var didAddNew = viewModel.AddNewServer(out serverIndex, i => { });
     //------------Assert----------------------------------
     Assert.IsNotNull(viewModel);
     Assert.IsFalse(didAddNew);
 }
开发者ID:Robin--,项目名称:Warewolf,代码行数:30,代码来源:ConnectControlViewModelTests.cs


示例2: ViewModel

        public ViewModel()
        {
            mgt = new ManagementClass("Win32_Processor");
            procs = mgt.GetInstances();

            CPU = new ObservableCollection<Model>();
            timer = new DispatcherTimer();
            random = new Random();
            time = DateTime.Now;
            cpuCounter = new PerformanceCounter();
            cpuCounter.CategoryName = "Processor";
            cpuCounter.CounterName = "% Processor Time";
            cpuCounter.InstanceName = "_Total";
            ramCounter = new PerformanceCounter("Memory", "Available MBytes");
            ProcessorID = GetProcessorID();
            processes = Process.GetProcesses();
            Processes = processes.Length;
            MaximumSpeed = GetMaxClockSpeed();
            LogicalProcessors = GetNumberOfLogicalProcessors();
            Cores = GetNumberOfCores();
            L2Cache = GetL2CacheSize();
            L3Cache = GetL3CacheSize();
            foreach (ManagementObject item in procs)
                L1Cache = ((UInt32)item.Properties["L2CacheSize"].Value / 2).ToString() + " KB";

            timer.Interval = TimeSpan.FromMilliseconds(1000);
            timer.Tick += timer_Tick;
            timer.Start();
            for (int i = 0; i < 60; i++)
            {
                CPU.Add(new Model(time, 0,0));
                time = time.AddSeconds(1);
            }
        }
开发者ID:jcw-,项目名称:sparrowtoolkit,代码行数:34,代码来源:ViewModel.cs


示例3: Dependencia_Insert

        public bool Dependencia_Insert(string KeySesion, string DependenciaName)
        {
            bool res = true;
            ObservableCollection<WAPP_USUARIO_SESION> Key = new ObservableCollection<WAPP_USUARIO_SESION>();

            try
            {
                using (var entity_ = new db_SeguimientoProtocolo_r2Entities())
                {
                    (from s in entity_.WAPP_USUARIO_SESION
                     where s.IdSesion == KeySesion
                     select s).ToList().ForEach(row =>
                     {
                         Key.Add(new WAPP_USUARIO_SESION()
                         {
                             IdUsuario = row.IdUsuario,
                             IdSesion = row.IdSesion
                         });
                     });
                    if (Key[0].IdSesion == KeySesion.ToString())
                    {
                        using (var entity = new db_SeguimientoProtocolo_r2Entities())
                        {
                            entity.SP_DependenciaInsert(DependenciaName);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var errr = ex.Message;
            }
            return res;
        }
开发者ID:slytsal,项目名称:wpfsistemalluviasv2,代码行数:34,代码来源:Cat_Dependencia_Repository.cs


示例4: GridViewModel

        public GridViewModel()
        {
            ResultData = new ObservableCollection<TestPointDataObject>();

            //get the unique test points
            var definedTestPoints = _resultValueTags.Where(dt => dt.Name.ToLower().Contains("testpoint")).GroupBy(dt => dt.Name.Split('.').First()).Select(grp => grp.First().Name.Split('.').First());
            //var q2 = _resultValueTags.Where(dt => Regex.Match(dt.Name.Split('.').Single((s) => s.Contains("test")), @"(testpoint)[\d+]", RegexOptions.IgnoreCase).Success);

            //Add the test point with a header value of it's number.
            foreach (string tp in definedTestPoints)
                ResultData.Add(new TestPointDataObject(Regex.Match(tp,@"[\d+]").Value));

            foreach (DataTag tag in _resultValueTags.Where(dt => dt.Name.ToLower().Contains("testpoint")))
                ResultData.ElementAt(Convert.ToInt32(Regex.Match(tag.Name, @"[\d+]").Value) - 1).Results.Add(new ResultDataObject(tag.Name,tag.Double));

            foreach (DataTag tag in _results)
            {
                tag.ValueChanged += Tag_ValueChanged;
                tag.ValueSet += Tag_ValueSet;
            }

            foreach (var v in ResultData)
            {

                _view = CollectionViewSource.GetDefaultView(v.Results);
                _view.GroupDescriptions.Add(new PropertyGroupDescription("Name", new ResultNameGrouper()));
            }
        }
开发者ID:drusteeby,项目名称:15106WPF,代码行数:28,代码来源:GridViewModel.cs


示例5: EventCatalogSingleton

        //Constructor
        private EventCatalogSingleton()
        {
            Events = new ObservableCollection<Event>();

            // The purpose of this is to make some instances of events. It creates instances of events and adds it to the observable collection.
            LoadEventAsync();
        }
开发者ID:TFrostholm,项目名称:EventMaker3000,代码行数:8,代码来源:EventCatalogSingleton.cs


示例6: AddProductViewModel

        public AddProductViewModel()
        {
            LstStatus = new ObservableCollection<ProductStatusDTO>();
            LstCategories = new ObservableCollection<ProductCategoryDTO>();

            ////Hide attributes for all the items sold in loose quantity
            ////This is default setting, which will be overriden once
            ////user checks the checkbox on screen.
            HideAttributesForLooseItems();

            ////Get Product status from database
            GetProductStatus();

            ////Get all active Product categories from database
            GetCategories();

            SaveProductCommand = new RelayCommand(SaveProductSetting);
            CancelProductCommand = new RelayCommand(CancelSetting);
            SearchProductCommand = new RelayCommand(SearchProducts);
            CancelSearchCommand = new RelayCommand(CancelSearch);
            GenerateBarCodeCommand = new RelayCommand(GenerateBarCode);

            LstProducts = new List<ProductDTO>();

            ///Get all products
            GetProducts(string.Empty);
        }
开发者ID:njmube,项目名称:RetailPOS,代码行数:27,代码来源:ProductViewModel.cs


示例7: AutoSuggestBox_TextChanged

        private async void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
        {
            try
            {
                if (sender.Text.Length != 0)
                {
                    //ObservableCollection<String>
                    var data = new ObservableCollection<string>();
                    var httpclient = new Noear.UWP.Http.AsyncHttpClient();
                    httpclient.Url("http://mobilecdn.kugou.com/new/app/i/search.php?cmd=302&keyword="+sender.Text);
                    var httpresult = await httpclient.Get();
                    var jsondata = httpresult.GetString();
                    var obj = Windows.Data.Json.JsonObject.Parse(jsondata);
                    var arryobj = obj.GetNamedArray("data");
                    foreach (var item in arryobj)
                    {
                        data.Add(item.GetObject().GetNamedString("keyword"));
                    }
                    sender.ItemsSource = data;
                    //sender.IsSuggestionListOpen = true;
                }
                else
                {
                    sender.IsSuggestionListOpen = false;
                }
            }
            catch (Exception)
            {

            }
        }
开发者ID:yszhangyh,项目名称:KuGouMusic-UWP,代码行数:31,代码来源:Search.xaml.cs


示例8: ConnectWindow

        public ConnectWindow()
        {
            InitializeComponent();

            try
            {
                IsAvailableServer = ServiceCtrlClass.ServiceIsInstalled("EpgTimer Service") == true ||
                    System.IO.File.Exists(SettingPath.ModulePath.TrimEnd('\\') + "\\EpgTimerSrv.exe") == true;

                btn_edit.Visibility = Visibility.Collapsed;

                ConnectionList = new ObservableCollection<NWPresetItem>(Settings.Instance.NWPreset);
                var nowSet = new NWPresetItem(DefPresetStr, Settings.Instance.NWServerIP, Settings.Instance.NWServerPort, Settings.Instance.NWWaitPort, Settings.Instance.NWMacAdd, Settings.Instance.NWPassword);
                int pos = ConnectionList.ToList().FindIndex(item => item.EqualsTo(nowSet, true));
                if (pos == -1)
                {
                    ConnectionList.Add(nowSet);
                    pos = ConnectionList.Count - 1;
                }
                if (IsAvailableServer == true)
                {
                    ConnectionList.Insert(0, new NWPresetItem("ローカル接続", "", 0, 0, "", new SerializableSecureString()));
                    pos++;
                }
                ConnectionList.Add(new NWPresetItem("<新規登録>", "", 0, 0, "", new SerializableSecureString()));

                listView_List.ItemsSource = ConnectionList;
                if (IsAvailableServer == false)
                {
                    Settings.Instance.NWMode = true;
                }
                listView_List.SelectedIndex = Settings.Instance.NWMode == true ? pos : 0;
            }
            catch { }
        }
开发者ID:nekopanda,项目名称:EDCB,代码行数:35,代码来源:ConnectWindow.xaml.cs


示例9: MachineStationsVM

		public MachineStationsVM(MachineVM machine, AccessType access)
			: base(access)
		{
            UnitOfWork = new SoheilEdmContext();
			CurrentMachine = machine;
            MachineDataService = new MachineDataService(UnitOfWork);
			MachineDataService.StationAdded += OnStationAdded;
			MachineDataService.StationRemoved += OnStationRemoved;
            StationDataService = new StationDataService(UnitOfWork);

			var selectedVms = new ObservableCollection<StationMachineVM>();
			foreach (var stationMachine in MachineDataService.GetStations(machine.Id))
			{
				selectedVms.Add(new StationMachineVM(stationMachine, Access, StationMachineDataService, RelationDirection.Reverse));
			}
			SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<StationVM>();
            foreach (var station in StationDataService.GetActives(SoheilEntityType.Machines, CurrentMachine.Id))
            {
                allVms.Add(new StationVM(station, Access, StationDataService));
            }
            AllItems = new ListCollectionView(allVms);

			IncludeCommand = new Command(Include, CanInclude);
			ExcludeCommand = new Command(Exclude, CanExclude);
		}
开发者ID:T1Easyware,项目名称:Soheil,代码行数:27,代码来源:MachineStationsVM.cs


示例10: DocumentManagerViewModel

        public DocumentManagerViewModel()
        {
            TaxPayerList = new ObservableCollection<TaxPayerEntity>();
            TaxPayerTypeList = new ObservableCollection<TaxPayerTypeEntity>();
            TaxPayerTypeEntityDictionary = new Dictionary<int, TaxPayerTypeEntity>();
            FileTypeList = new ObservableCollection<FileTypeEntity>();
            FileTypeDictionary = new Dictionary<int, FileTypeEntity>();
            UserEntityDictionary = new Dictionary<int, UserEntity>();

            DocumentViewModel = new DocumentViewModel();
            DocumentViewModel.BeginLoadings += BeginLoading;
            DocumentViewModel.FinishLoadings += FinishLoading;

            documentManagerContext = new DocumentManager.Web.DocumentManagerDomainContext();
            OnAddTaxPayer = new DelegateCommand(onAddTaxPayer);
            OnAddProject = new DelegateCommand(onAddProject, canAddProject);
            OnModifyTaxPayer = new DelegateCommand(onModifyTaxPayer, canModifyTaxPayer);
            OnDeleteTaxPayer = new DelegateCommand(onDeleteTaxPayer, canDeleteTacPayer);

            OnRefresh = new DelegateCommand(onRefresh);
            OnDoubleClickList = new DelegateCommand(onDoubleClickList);

            taxPayerDocumentSource = new EntityList<Web.Model.taxpayerdocument>(documentManagerContext.taxpayerdocuments);
            taxPayerDocumentLoader = new DomainCollectionViewLoader<Web.Model.taxpayerdocument>(
                LoadTaxPayerDocument,
                LoadTaxPayerDocument_Complete
                );
            taxPayerDocumentView = new DomainCollectionView<Web.Model.taxpayerdocument>(taxPayerDocumentLoader, taxPayerDocumentSource);
        }
开发者ID:YHTechnology,项目名称:DocumentManager,代码行数:29,代码来源:DocumentManagerViewModel.cs


示例11: ServersList

        public ServersList(ServersListMessage msg)
        {
            if (msg == null) throw new ArgumentNullException("msg");

            m_collection = new ObservableCollection<ServersListEntry>(msg.servers.Select(entry => new ServersListEntry(entry)));
            m_readOnlyCollection = new ReadOnlyObservableCollection<ServersListEntry>(m_collection);
        }
开发者ID:Geraff,项目名称:BehaviorIsManaged,代码行数:7,代码来源:ServersList.cs


示例12: PaymentButtonGroupViewModel

 public PaymentButtonGroupViewModel(ICaptionCommand makePaymentCommand, ICaptionCommand settleCommand, ICaptionCommand closeCommand)
 {
     _makePaymentCommand = makePaymentCommand;
     _settleCommand = settleCommand;
     _closeCommand = closeCommand;
     _paymentButtons = new ObservableCollection<CommandButtonViewModel<PaymentTemplate>>();
 }
开发者ID:yemreguney,项目名称:SambaPOS-3,代码行数:7,代码来源:PaymentButtonGroupViewModel.cs


示例13: ConfigurationWindow

        public ConfigurationWindow()
        {
            InitializeComponent();
            DataContext = this;

            ObservableCollection<Personality> personalities = new ObservableCollection<Personality>();
            // Add our default personality
            personalities.Add(Personality.Default());
            foreach (Personality personality in Personality.AllFromDirectory())
            {
                personalities.Add(personality);
            }
            // Add local personalities
            foreach (Personality personality in personalities)
            {
                Logging.Debug("Found personality " + personality.Name);
            }
            Personalities = personalities;

            SpeechResponderConfiguration configuration = SpeechResponderConfiguration.FromFile();

            foreach (Personality personality in Personalities)
            {
                if (personality.Name == configuration.Personality)
                {
                    Personality = personality;
                    break;
                }
            }
        }
开发者ID:cmdrmcdonald,项目名称:EliteDangerousDataProvider,代码行数:30,代码来源:ConfigurationWindow.xaml.cs


示例14: MenuGeneral

        public MenuGeneral()
        {
            //Delegate pour exécuter du code personnalisé lors du changement de langue de l'UI.
            CultureManager.UICultureChanged += CultureManager_UICultureChanged;

            mapLangue = new ObservableCollection<LangueUI>();
            //Le tag de langue IETF (ie: fr-CA) utilisé directement pour changer la langue d'affichage.
            //Récupéré selon la Langue active.
            string codeLangueActif;

            //Si l'utilisateur est connecté, utilise la langue sauvegarder sous son profil.
            if (App.MembreCourant.IdMembre != null)
            {
                codeLangueActif = App.MembreCourant.LangueMembre.IETF;
            }
            else
            {
                //Sinon, utilise la valeur par défault tel que défini sous App.
                codeLangueActif = App.LangueInstance.IETF;
            }

            mapLangue.Add(francais);
            mapLangue.Add(anglais);
            //Dans le dictionnaire, trouve l'élément qui a le tag IETF équivalent à selui enregistré sous codeLangueActif et le met à actif.
            mapLangue.FirstOrDefault(l => l.LangueSys.IETF == codeLangueActif).Actif = true;

            InitializeComponent();
            //Configure la source de notre dataGrid.
            dgLangues.ItemsSource = mapLangue;
        }
开发者ID:Nutritia,项目名称:nutritia,代码行数:30,代码来源:MenuGeneral.xaml.cs


示例15: btnCerca_Click

 private void btnCerca_Click(object sender, RoutedEventArgs e)
 {
     
     var list = dag.cercaSoggiorni((DateTime)datePickerArrivo.SelectedDate, (DateTime)datePickerPartenza.SelectedDate, cliente);
     soggiorniResult = new ObservableCollection<Soggiorno>(list);
     dataGridSoggiorni.DataContext = soggiorniResult;
 }
开发者ID:eddiez,项目名称:soggiorni,代码行数:7,代码来源:CercaSoggiornoWindow.xaml.cs


示例16: TVsViewDefinition

		public TVsViewDefinition()
		{
			this.groupDescriptions = new ObservableCollection<GroupDescription>();
			this.groupDescriptions.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnGroupByCollectionChanged);
			this.Title = "Televisions";
			this.VisibleDays = 5;
		}
开发者ID:netintellect,项目名称:PluralsightSpaJumpStartFinal,代码行数:7,代码来源:TVsViewDefinition.cs


示例17: BroadcastViewModel

        public BroadcastViewModel()
        {
            Positions = new ObservableCollection<Position>();
            Positions.CollectionChanged += Positions_CollectionChanged;

            TryDownloadMyPositions(50);
        }
开发者ID:JorgeCupi,项目名称:SmartGuard,代码行数:7,代码来源:BroadcastViewModel.cs


示例18: CalendarViewModel

        public CalendarViewModel(ICalendarService calendarService, IRegionManager regionManager)
        {
            this.synchronizationContext = SynchronizationContext.Current ?? new SynchronizationContext();

            this.openMeetingEmailCommand = new DelegateCommand<Meeting>(this.OpenMeetingEmail);

            this.meetings = new ObservableCollection<Meeting>();

            this.calendarService = calendarService;
            this.regionManager = regionManager;

            this.calendarService.BeginGetMeetings(
                r =>
                {
                    var meetings = this.calendarService.EndGetMeetings(r);

                    this.synchronizationContext.Post(
                        s =>
                        {
                            foreach (var meeting in meetings)
                            {
                                this.Meetings.Add(meeting);
                            }
                        },
                        null);
                },
                null);
        }
开发者ID:eslahi,项目名称:prism,代码行数:28,代码来源:CalendarViewModel.cs


示例19: OnPublished

        protected override async void OnPublished(object data)
        {
            try
            {
                IsBusy = true;

                var authorisationNodes = await authorisationManagerServiceManager.GetAuthorisationNodes();
                Activities = new ObservableCollection<ActivityNode>(authorisationNodes.ActivityNodes);
                Roles = new ObservableCollection<RoleNode>(authorisationNodes.RoleNodes);
                Users = new ObservableCollection<UserNode>(authorisationNodes.UserNodes);

                ResetStatus();
            }
            catch (Exception ex)
            {
                ShowMessage(new Message()
                {
                    MessageType = MessageTypeEnum.Error,
                    Text = ex.Message
                }, true);

                IsBusy = false;
            }
            finally
            {
                OnPropertyChanged("");
            }

            Logger.Log("ConfigurationAuthorisationViewModel OnPublished complete", Category.Info, Priority.None);
        }
开发者ID:grantcolley,项目名称:authorisationmanager,代码行数:30,代码来源:ConfigurationAuthorisationViewModel.cs


示例20: DesignTimeCategoryListViewModel

 public DesignTimeCategoryListViewModel()
 {
     Categories = new ObservableCollection<Category>
     {
         new Category {Name = "Design Time Category 1"}
     };
 }
开发者ID:Rumpel78,项目名称:MoneyFox.Windows,代码行数:7,代码来源:DesignTimeCategoryListViewModel.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ObservableCollectionEx类代码示例发布时间:2022-05-24
下一篇:
C# ObservableAsPropertyHelper类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap