本文整理汇总了C#中BindableCollection.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# BindableCollection.AddRange方法的具体用法?C# BindableCollection.AddRange怎么用?C# BindableCollection.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BindableCollection
的用法示例。
在下文中一共展示了BindableCollection.AddRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnViewLoaded
protected override void OnViewLoaded(object view)
{
base.OnViewLoaded(view);
Styles = new BindableCollection<BaseContent>();
Styles.AddRange(Service.PoITypes.Where(k => k.Style != null).ToList());
}
示例2: AppearanceViewModel
public AppearanceViewModel(ILog log, IDispatcherSchedulerProvider scheduler, IStandardDialog standardDialog,
BindableCollection<string> fontSizesCollection,
BindableCollection<Color> accentColorsCollection,
BindableCollection<ThemeItemViewModel> themesCollection)
: base(log, scheduler, standardDialog)
{
this.SetupHeader(scheduler, "Appearance");
FontSizes = fontSizesCollection;
FontSizes.AddRange(new[] {FONT_SMALL, FONT_LARGE});
SelectedFontSize = AppearanceManager.Current.FontSize == FontSize.Large ? FONT_LARGE : FONT_SMALL;
AccentColors = accentColorsCollection;
foreach (var accentColor in _accentColors)
{
AccentColors.Add(accentColor);
}
// add the default themes
Themes = themesCollection;
Themes.AddRange(new[]
{
new ThemeItemViewModel {Name = "Dark", Source = AppearanceManager.DarkThemeSource},
new ThemeItemViewModel {Name = "Light", Source = AppearanceManager.LightThemeSource}
});
SyncThemeAndColor();
AppearanceManager.Current.PropertyChanged += OnAppearanceManagerPropertyChanged;
}
示例3: ChangelogPageViewModel
public ChangelogPageViewModel()
{
ReleaseNotes = new BindableCollection<Release>();
if (Execute.InDesignMode) {
ReleaseNotes.AddRange(FakeData.ReleaseNotes);
}
}
示例4: LoadPageContent
private async void LoadPageContent()
{
UserFundraisingPages = new BindableCollection<FundraisingPage>();
UserDonations = new BindableCollection<Donation>();
UserFundraisingPages.AddRange(await _accountRepository.GetFundraisingPagesForUser(UserHelperIsolatedStorage.User.Email));
UserDonations.AddRange(await _accountRepository.GetDonationsForUser());
AccountInformation = UserHelperIsolatedStorage.User;
}
示例5: MenuViewModel
public MenuViewModel(IEventAggregator eventAggregator)
{
EventAggregator = eventAggregator;
SalesItems = new BindableCollection<IMenuItem>()
{
new MenuItemViewModel<SummaryViewModel>("Balance Sheet"),
new MenuItemViewModel<TodaysCustomerTransactionsViewModel>("Todays Transactions", o => o.StartDate = DateTime.Today),
};
AdministrationItems = new BindableCollection<IMenuItem>()
{
new MenuItemViewModel<ProductsViewModel>("Products"),
new MenuItemViewModel<CustomersViewModel>("Customers"),
new MenuItemViewModel<DiscountsViewModel>("Discounts")
};
Items = new BindableCollection<IMenuItem>();
Items.AddRange(SalesItems);
Items.AddRange(AdministrationItems);
}
示例6: SynchronizeDiagnozy
/// <summary>
/// button evet click handler, handles Diagnozy synchronization
/// </summary>
public void SynchronizeDiagnozy()
{
ambulanceDiagonzies = new BindableCollection<Cis_Diagnoza>();
AmbulanceSynchronizationDomainContext ambulance = _serviceLocator.GetInstance<AmbulanceSynchronizationDomainContext>();
EntityQuery<Cis_Diagnoza> query = ambulance.GetCis_DiagnozaQuery();
EntityQuery<Diagnozy> query2 = _laboratoryDomainContext.GetAllDiagnoziesQuery();
List<IResult> results = new List<IResult>();
results.Add(Show.Busy());
LoadData<Cis_Diagnoza> loadResult = new LoadData<Cis_Diagnoza>(ambulance,query,LoadBehavior.RefreshCurrent,(sender) =>
{
ambulanceDiagonzies.Clear();
ambulanceDiagonzies.AddRange(((LoadOperation<Cis_Diagnoza>)sender).Entities);
}
);
LoadData<Diagnozy> loadResult2 = new LoadData<Diagnozy>(_laboratoryDomainContext, query2, LoadBehavior.RefreshCurrent, (sender) =>
{
laboratoryDiagnozy.Clear();
laboratoryDiagnozy.AddRange(((LoadOperation<Diagnozy>)sender).Entities);
bool found = false;
foreach (var item in ambulanceDiagonzies)
{
for (int i = 0; i < laboratoryDiagnozy.Count; i++)
{
found = false;
if (item.Nazov == laboratoryDiagnozy[i].nazov && item.Poznamka == laboratoryDiagnozy[i].popis)
{
laboratoryDiagnozy.RemoveAt(i);
found = true;
break;
}
}
if (found == false)
{
Diagnozy novaDiagnoza = new Diagnozy();
novaDiagnoza.nazov = item.Nazov;
novaDiagnoza.popis = item.Poznamka;
_laboratoryDomainContext.Diagnozies.Add(novaDiagnoza);
}
}
_laboratoryDomainContext.SubmitChanges();
Coroutine.BeginExecuteFor(Show.NotBusy(), this);
}
);
results.Add(loadResult);
results.Add(loadResult2);
Coroutine.BeginExecuteFor(results, this);
}
示例7: does_not_fire_a_collectionchanged_event_for_each_item_in_addrange
public void does_not_fire_a_collectionchanged_event_for_each_item_in_addrange()
{
var collection = new BindableCollection<string>();
var eventsFired = 0;
collection.CollectionChanged += (source, args) => { eventsFired++; };
collection.AddRange(new[]
{
"abc", "def"
});
Assert.That(eventsFired, Is.EqualTo(1), "The CollectionChanged event should only have fired once.");
}
示例8: FlyoutSettingsViewModel
public FlyoutSettingsViewModel(MainManager mainManager, ILogger logger, DebugViewModel debugViewModel)
{
_logger = logger;
_debugViewModel = debugViewModel;
MainManager = mainManager;
Header = "Settings";
Position = Position.Right;
GeneralSettings = SettingsProvider.Load<GeneralSettings>();
LogLevels = new BindableCollection<string>();
LogLevels.AddRange(LogLevel.AllLoggingLevels.Select(l => l.Name));
PropertyChanged += KeyboardUpdater;
mainManager.OnEnabledChangedEvent += MainManagerOnOnEnabledChangedEvent;
mainManager.EffectManager.OnEffectChangedEvent += EffectManagerOnOnEffectChangedEvent;
}
示例9: AddRangeUsesDispatcherToAddElements
public void AddRangeUsesDispatcherToAddElements()
{
var itemsToAdd = new[] { new Element(), new Element() };
var existingItems = new[] { new Element() };
var collection = new BindableCollection<Element>(existingItems);
var dispatcher = new TestDispatcher();
Execute.Dispatcher = dispatcher;
collection.AddRange(itemsToAdd);
Assert.That(collection, Is.EquivalentTo(existingItems));
Assert.NotNull(dispatcher.SendAction);
dispatcher.SendAction();
Assert.AreEqual(existingItems.Concat(itemsToAdd), collection);
}
示例10: when_AddRange_is_called_and_IsNotifying_is_false_then_Reset_event_fired
public void when_AddRange_is_called_and_IsNotifying_is_false_then_Reset_event_fired()
{
var testSchedulerProvider = new TestDispatcherSchedulerProvider();
var result = false;
var bindableCollection = new BindableCollection<int>(testSchedulerProvider);
bindableCollection.CollectionChanged += (sender, args) =>
{
if (args.Action == NotifyCollectionChangedAction.Reset)
{
result = true;
}
};
bindableCollection.IsNotifying = false;
bindableCollection.AddRange(Enumerable.Range(0, 1));
Assert.That(result, Is.False);
}
示例11: LoadModules
public static ObservableCollection<IModule> LoadModules(IEnumerable<Lazy<IModule, IModuleMetadata>> modules)
{
BindableCollection<IModule> existingModules = new BindableCollection<IModule>();
BindableCollection<IModule> authorizedModules = new BindableCollection<IModule>();
try {
existingModules.AddRange(from m in modules orderby m.Metadata.Order select m.Value);
foreach (IModule module in existingModules) {
if (module.Module.ToString() == ModuleNames.Dashboard.ToString() && module.Module.ToString() != "Inventory") {
authorizedModules.Add(module);
}else {
if (!module.IsButtonModule && module.Module.ToString() != "Inventory")
{
authorizedModules.Add(module);
}else {
if (IsAuthorized(module.Module.ToString()) && module.Module.ToString() != "Inventory")
{
authorizedModules.Add(module);
}
}
}
}
return authorizedModules;
}catch {
throw;
}finally {
existingModules = null;
authorizedModules = null;
}
}
示例12: when_RemoveRange_is_called_then_Reset_event_fired
public void when_RemoveRange_is_called_then_Reset_event_fired()
{
var testSchedulerProvider = new TestDispatcherSchedulerProvider();
var result = false;
var bindableCollection = new BindableCollection<int>(testSchedulerProvider);
var items = Enumerable.Range(0, 1).ToList();
bindableCollection.AddRange(items);
bindableCollection.CollectionChanged += (sender, args) =>
{
if (args.Action == NotifyCollectionChangedAction.Reset)
{
result = true;
}
};
bindableCollection.RemoveRange(items);
Assert.That(result, Is.True);
}
示例13: when_items_are_added_those_items_are_pumped_onto_AddedItemsCollectionChanged
public void when_items_are_added_those_items_are_pumped_onto_AddedItemsCollectionChanged()
{
var testSchedulerProvider = new TestDispatcherSchedulerProvider();
var results = new List<Guid>();
var bindableCollection = new BindableCollection<Guid>(testSchedulerProvider);
bindableCollection.AddedItemsCollectionChanged
.Subscribe(x => results.AddRange(x));
var items = Enumerable.Range(0, 10)
.Select(_ => Guid.NewGuid())
.ToList();
bindableCollection.AddRange(items);
var intersectionCount = results.Intersect(items).Count();
Assert.That(intersectionCount, Is.EqualTo(items.Count));
}
示例14: GetSortedSeasons
//this returns seasons populated down to the category level.
public async Task<BindableCollection<Season>> GetSortedSeasons()
{
TeamResponse response = await ServiceAccessor.GetTeams();
if (response.status == SERVICE_RESPONSE.SUCCESS)
{
BindableCollection<Team> teams = response.teams;
BindableCollection<Season> seasons = new BindableCollection<Season>();
foreach (Team team in teams)
{
BindableCollection<Season> teamSeason = await GetPopulatedSeasons(team);
if (teamSeason != null)
{
seasons.AddRange(teamSeason);
}
}
return new BindableCollection<Season>(seasons.OrderByDescending(s => s.year));
}
return null;
}
示例15: AddRangeFiresCollectionChangingBeforeAddingItems
public void AddRangeFiresCollectionChangingBeforeAddingItems()
{
var collection = new BindableCollection<Element>();
var changedEvents = new List<NotifyCollectionChangedEventArgs>();
collection.CollectionChanging += (o, e) =>
{
changedEvents.Add(e);
Assert.AreEqual(0, collection.Count);
};
collection.AddRange(new[] { new Element() });
Assert.AreEqual(1, changedEvents.Count);
var changedEvent = changedEvents[0];
Assert.AreEqual(NotifyCollectionChangedAction.Reset, changedEvent.Action);
}