本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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.");
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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");
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例15: AllPlayerViewModel
public AllPlayerViewModel(List<Player> playerList)
{
Players = new BindableCollection<PlayerViewModel>();
foreach (Player item in playerList)
{
Players.Add(new PlayerViewModel(item));
}
}