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


C# BindableCollection.Add方法代码示例

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


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

示例1: DynamicColumnManagementViewModel

        public DynamicColumnManagementViewModel(ILog log, IDispatcherSchedulerProvider scheduler, IStandardDialog standardDialog, IDynamicColumnManagementService service,
                                                BindableCollection<DynamicColumn> columnsCollection, 
                                                BindableCollection<IToolBarItem> toolBarItemsCollection,
                                                Func<DynamicColumnEditViewModel> editViewModelFactory,
                                                IToolBarService toolBarService)
            : base(log, scheduler, standardDialog)
        {
            _service = service;
            _editViewModelFactory = editViewModelFactory;

            Disposables.Add(service);

            Columns = columnsCollection;

            ToolBarItems = toolBarItemsCollection;

            var saveToolBarItem = toolBarService.CreateToolBarButtonItem();
            saveToolBarItem.DisplayName = "Save";
            _saveCommand = new DelegateCommand(() =>
            {
                ClosingStrategy.Close();
            });
            saveToolBarItem.Command = _saveCommand;
            ToolBarItems.Add(saveToolBarItem);

            var cancelToolBarItem = toolBarService.CreateToolBarButtonItem();
            cancelToolBarItem.DisplayName = "Cancel";
            cancelToolBarItem.Command = ClosingStrategy.CloseCommand;
            ToolBarItems.Add(cancelToolBarItem);
        }
开发者ID:ganesum,项目名称:Blitz,代码行数:30,代码来源:DynamicColumnManagementViewModel.cs

示例2: BindableCollectionEnumeratorFrozen

        public void BindableCollectionEnumeratorFrozen()
        {
            // Initialize the test data
            BindableCollection<Contact> customers = new BindableCollection<Contact>();
            customers.Add(new Contact() { Name = "Paul" });
            customers.Add(new Contact() { Name = "Greg" });
            customers.Add(new Contact() { Name = "Sam" });

            // Enumerate over the items, and whilst enumerating, add some new items. The new items
            // should be added and should not effect the items being enumerated.
            int enumerated = 0;
            foreach (Contact customer in customers)
            {
                enumerated++;
                // This would normally raise an InvalidOperationException
                customers.Add(new Contact() { Name = "Jack " + enumerated });
            }

            // Check that the items were actually added and enumerated correctly
            Assert.AreEqual(3, enumerated);
            Assert.AreEqual("Paul", customers[0].Name);
            Assert.AreEqual("Greg", customers[1].Name);
            Assert.AreEqual("Sam", customers[2].Name);
            Assert.AreEqual("Jack 1", customers[3].Name);
            Assert.AreEqual("Jack 2", customers[4].Name);
            Assert.AreEqual("Jack 3", customers[5].Name);
        }
开发者ID:svn2github,项目名称:bindablelinq,代码行数:27,代码来源:BindableCollectionTests.cs

示例3: RemoveEventRaised

        public void RemoveEventRaised()
        {
            BindableCollection<SimpleBusinessObject> lBindableCollection = new BindableCollection<SimpleBusinessObject>();
            bool removingRaised = false;
            lBindableCollection.ItemRemovedEvent += delegate(object sender, ItemRemovedEventArgs ea)
                {
                    removingRaised = true;
                };

            Assert.IsFalse(removingRaised);

            lBindableCollection.Add(new SimpleBusinessObject());

            Assert.IsFalse(removingRaised);

            lBindableCollection.RemoveAt(0);

            Assert.IsTrue(removingRaised);

            SimpleBusinessObject sbo = new SimpleBusinessObject();
            lBindableCollection.Add(sbo);
            removingRaised = false;

            lBindableCollection.Remove(sbo);

            Assert.IsTrue(removingRaised);
        }
开发者ID:BackupTheBerlios,项目名称:boxerp-svn,代码行数:27,代码来源:BindableCollectionTests.cs

示例4: raises_a_collectionchanged_event_for_each_item_added

        public void raises_a_collectionchanged_event_for_each_item_added()
        {
            var collection = new BindableCollection<string>();
            var eventsFired = 0;
            collection.CollectionChanged += (source, args) => { eventsFired++; };

            collection.Add("abc");
            collection.Add("def");

            Assert.That(eventsFired, Is.EqualTo(2), "The collection should have raised a CollectionChanged event twice.");
        }
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:11,代码来源:A_bindable_collection.cs

示例5: ToBindableCollection

 public static BindableCollection<string> ToBindableCollection(this ADOTabular.ADOTabularDatabaseCollection databases)
 {
     var ss = new BindableCollection<string>();
     foreach (var dbname in databases)
     { ss.Add(dbname); }
     return ss;
 }
开发者ID:votrongdao,项目名称:DaxStudio,代码行数:7,代码来源:DatabaseCollectionExtensions.cs

示例6: ObtenerSubLineas

        public BindableCollection<SubLineaProducto> ObtenerSubLineas(int id)
        {
            db.cmd.CommandText = "SELECT * FROM SubLineaProducto WHERE [email protected]";
            db.cmd.Parameters.AddWithValue("idLinea", id);
            SqlDataReader reader;
            BindableCollection<SubLineaProducto> lstSubLinea = new BindableCollection<SubLineaProducto>();
            try
            {
                db.conn.Open();
                reader=db.cmd.ExecuteReader();
                while (reader.Read())
                {
                    SubLineaProducto slp = new SubLineaProducto();
                    slp.IdLinea = id;
                    slp.Nombre=reader["Nombre"].ToString();
                    slp.IdSubLinea = Int32.Parse(reader["IdSubLinea"].ToString());
                    slp.Abreviatura = reader["Abreviatura"].ToString();
                    lstSubLinea.Add(slp);
                }
                db.cmd.Parameters.Clear();
                reader.Close();
                db.conn.Close();

            }
            catch (SqlException e)
            {
                Console.WriteLine(e);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace.ToString());
            }

            return lstSubLinea;
        }
开发者ID:alfonsobp,项目名称:made-in-house,代码行数:35,代码来源:SubLineaProductoSQL.cs

示例7: _getUsers

        IObservableCollection<DirectoryUser> _getUsers(string filter)
        {
            var entry = new DirectoryEntry("LDAP://" + _settings.LdapPath);
            var ds = new DirectorySearcher(entry)
                     {
                         Filter = filter,
                         SearchScope = SearchScope.OneLevel
                     };

            var results = new BindableCollection<DirectoryUser>();

            using (entry)
            using (ds)
            {
                var searchResults = ds.FindAll();

                foreach (SearchResult searchResult in searchResults)
                {
                    var userPrincipalName = searchResult.Properties["userPrincipalName"];
                    var fullname = searchResult.Properties["cn"];

                    results.Add(new DirectoryUser(userPrincipalName.Count > 0 ? (string)userPrincipalName[0] : "", fullname.Count > 0 ? (string)fullname[0] : ""));
                }
            }
            return results;
        }
开发者ID:henninga,项目名称:AssetTracker,代码行数:26,代码来源:DirectoryService.cs

示例8: BuscarModosPago

        public BindableCollection<ModoPago> BuscarModosPago()
        {
            BindableCollection<ModoPago> listaModoPagos = new BindableCollection<ModoPago>(); ;
            SqlConnection conn = new SqlConnection(Properties.Settings.Default.inf245g4ConnectionString);
            SqlCommand cmd = new SqlCommand();
            SqlDataReader reader;

            cmd.CommandText = "SELECT * FROM ModoPago";
            cmd.CommandType = CommandType.Text;
            cmd.Connection = conn;

            try
            {
                conn.Open();
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    ModoPago mp = new ModoPago();
                    mp.IdModoPago = reader.IsDBNull(reader.GetOrdinal("idModoPago")) ? -1 : (int)reader["idModoPago"];
                    mp.Nombre = reader.IsDBNull(reader.GetOrdinal("nombre")) ? null : reader["nombre"].ToString();
                    listaModoPagos.Add(mp);
                }

                conn.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.StackTrace.ToString());
            }

            return listaModoPagos;
        }
开发者ID:alfonsobp,项目名称:made-in-house,代码行数:33,代码来源:ModoPagoSQL.cs

示例9: DataPresentationViewModel

 public DataPresentationViewModel()
 {
     DisplayName = "Presentation";
       RefreshBtnContent = "Refresh";
       Diagrams = new BindableCollection<DiagramViewModel>();
       LocationsLbl = "Locations:";
       Locations = new BindableCollection<LocationViewModel>();
       GetLocations();
       TimeSpanLbl = "Timespan:";
       TimeSpans = new BindableCollection<string>();
       TimeSpans.Add("Year");
       TimeSpans.Add("Month");
       TimeSpans.Add("Week");
       TimeSpans.Add("Day");
       TimeSpans.Add("Hour");
 }
开发者ID:rMb93,项目名称:BasteleiApp,代码行数:16,代码来源:DataPresentationViewModel.cs

示例10: FingerTrackingOptionsViewModel

        public FingerTrackingOptionsViewModel()
        {
            Colors = new BindableCollection<Color>();

            foreach (var property in typeof(Color).GetProperties().Where(p => p.PropertyType == typeof(Color)))
            {
                Colors.Add((Color)property.GetValue(new Color()));
            }

            MinContourArea = 100;
            ConvexHullCW = false;

            ConvexHullColor = Color.Green;
            ContourHighlightColor = Color.Blue;
            DefectStartPointHighlightColor = Color.Violet;
            DefectDepthPointHighlightColor = Color.Black;
            DefectEndPointHighlightColor = Color.Yellow;
            DefectLinesColor = Color.Red;

            SelectedMethod = 2;

            TrackOnlyControlPoint = false;

            if (Execute.InDesignMode)
                LoadDesignTimeData();
        }
开发者ID:vladimirdjurdjevic,项目名称:soft,代码行数:26,代码来源:FingerTrackingOptionsViewModel.cs

示例11: EndoscopyViewModel

        public EndoscopyViewModel(IEventAggregator events, int sessionId)
        {
            DisplayName = "Nội soi";
            if (App.Current != null)
            {
                _esClinicContext = App.Current.EsClinicContext;
            }
            _events = events;
            _sessionId = sessionId;
          
            Photos = new BindableCollection<TmpPhoto>();

            IsEnabledScopy = true;
            NotifyOfPropertyChange(() => IsEnabledScopy);

            EsTypes = new BindableCollection<EndoscopyType>();
            var esTypes = _esClinicContext.EndoscopyTypes.ToList();
            
            foreach (var esType in esTypes)
            {
                EsTypes.Add(esType);
            }

            Cameras = new BindableCollection<Camera>();
            foreach (var camera in CameraService.AvailableCameras)
            {
                Cameras.Add(camera);
            }

            _selectedCamera = Cameras.FirstOrDefault();
        }
开发者ID:narukunegu,项目名称:ESClinic,代码行数:31,代码来源:EndoscopyViewModel.cs

示例12: DateTimeViewModel

        public DateTimeViewModel()
        {
            Days = new BindableCollection<int>();
            Months = new Dictionary<int, string>();
            Years = new BindableCollection<int>();
            Hours = new BindableCollection<int>();
            Minutes = new BindableCollection<int>();

            for (var i = 0; i < 24; i++)
                Hours.Add(i + 1);
            for (var i = 0; i < 60; i++)
                Minutes.Add(i);
            for (var i = DateTime.Now.Year - 20; i < DateTime.Now.Year + 20; i++)
                Years.Add(i);

            SelectedYear = DateTime.Now.Year;

            OnMonthsChanged();

            SelectedDay = DateTime.Now.Day;

            SelectedMonth = Months.Single(c => c.Key == DateTime.Now.Month);

            SelectedHour = DateTime.Now.Hour;
            SelectedMinute = DateTime.Now.Minute;
        }
开发者ID:schultyy,项目名称:octocal,代码行数:26,代码来源:DateTimeViewModel.cs

示例13: createPoints

 private static IObservableCollection<DistanceViewModel> createPoints(int begin, int end, int step)
 {
     if (end <= 0) return null;
     var collection = new BindableCollection<DistanceViewModel>();
     for (var i = begin; i < end; i = i + step)
         collection.Add(new DistanceViewModel(i));
     return collection.Count > 0 ? collection : null;
 }
开发者ID:benediktfunk,项目名称:RunTimeCalc,代码行数:8,代码来源:BindableCollectionExtensions.cs

示例14: createTicks

 private static IObservableCollection<TimeViewModel> createTicks(int count)
 {
     if (count <= 0) return null;
     var collection = new BindableCollection<TimeViewModel>();
     for (var i = 0; i < count; i++)
         collection.Add(new TimeViewModel(i));
     return collection.Count > 0 ? collection : null;
 }
开发者ID:benediktfunk,项目名称:RunTimeCalc,代码行数:8,代码来源:BindableCollectionExtensions.cs

示例15: AllPlayerViewModel

 public AllPlayerViewModel(List<Player> playerList)
 {
     Players = new BindableCollection<PlayerViewModel>();
     foreach (Player item in playerList)
     {
         Players.Add(new PlayerViewModel(item));
     }
 }
开发者ID:vlangloi,项目名称:BaconMaster,代码行数:8,代码来源:AllPlayerViewModel.cs


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