本文整理汇总了C#中ObservableCollection.ForEach方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.ForEach方法的具体用法?C# ObservableCollection.ForEach怎么用?C# ObservableCollection.ForEach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.ForEach方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UserPageViewModel
public UserPageViewModel()
{
Title = "Пользователи";
Users = new ObservableCollection<CheckedItemViewModel<User>>(ClientManager.SecurityConfiguration.Users.Select(item => new CheckedItemViewModel<User>(item)));
SelectAllCommand = new RelayCommand(() => Users.ForEach(item => item.IsChecked = true));
SelectNoneCommand = new RelayCommand(() => Users.ForEach(item => item.IsChecked = false));
}
示例2: DoorPageViewModel
public DoorPageViewModel()
{
Title = "Точки доступа";
Doors = new ObservableCollection<CheckedItemViewModel<GKDoor>>(GKManager.Doors.Select(item => new CheckedItemViewModel<GKDoor>(item)));
SelectAllCommand = new RelayCommand(() => Doors.ForEach(item => item.IsChecked = true));
SelectNoneCommand = new RelayCommand(() => Doors.ForEach(item => item.IsChecked = false));
}
示例3: ZonePageViewModel
public ZonePageViewModel()
{
Title = "Зоны";
Zones = new ObservableCollection<CheckedItemViewModel<CommonZoneViewModel>>();
foreach (var zone in GKManager.SKDZones)
{
var zoneViewModel = new CommonZoneViewModel(zone);
Zones.Add(new CheckedItemViewModel<CommonZoneViewModel>(zoneViewModel));
}
SelectAllCommand = new RelayCommand(() => Zones.ForEach(item => item.IsChecked = true));
SelectNoneCommand = new RelayCommand(() => Zones.ForEach(item => item.IsChecked = false));
}
示例4: 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);
}
示例5: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
var resources = new ObservableCollection<Resource>();
resources.Add(new Resource()
{
Name = "Gold",
});
resources.Add(new Resource()
{
Name = "Aluminium",
});
resources.Add(new Resource()
{
Name = "Helium-3",
});
resources.ForEach(r => MongoHelpers.SaveData(r));
var buildings = new ObservableCollection<Building>();
for (var i = 0; i < 3; i++)
{
var b = new Building();
b.Name = "name" + i;
b.Resources = new ObservableCollection<ResourceInBuilding>()
{
new ResourceInBuilding(){ ResourceId = resources[i].Id, ProducePerTurn = 0, UsefullType = UsefullTypes.ForBuilding }
};
b.BuildsRequested = i*12;
b.BuildsCompleted = 0;
buildings.Add(b);
}
buildings.ForEach(b => MongoHelpers.SaveData(b));
}
示例6: SetBooking
public void SetBooking(Booking booking)
{
if (booking == null)
return;
_booking = booking;
FareInfo = booking.FareInfo;
OnPropertyChanged(() => FareInfo);
if (booking.FareInfo != null)
{
FareInfoItems = new ObservableCollection<FareTypeInfoItemViewModel>(booking.FareInfo.Items.Select(i => new FareTypeInfoItemViewModel(i, false)));
OnPropertyChanged(() => FareInfoItems);
FareInfoItems.ForEach(i => i.IsSelected = i.FareInfoItem.FareType == booking.FareType);
SelectedFareInfoItem = FareInfoItems.SingleOrDefault(i => i.IsSelected);
AcceptedTnC = SelectedFareInfoItem != null;
OnPropertyChanged(() => AcceptedTnC);
}
else
{
FareInfoItems = new ObservableCollection<FareTypeInfoItemViewModel>();
OnPropertyChanged(() => FareInfoItems);
SelectedFareInfoItem = null;
}
}
示例7: FilterEventsViewModel
public FilterEventsViewModel(Filter filter)
{
FilterEventViewModels = new ObservableCollection<FilterEventViewModel>(Enum.GetValues(typeof(JournalType)).Cast<JournalType>().Select(x => new FilterEventViewModel(x)));
FilterEventViewModels.ForEach(x =>
{
x.IsChecked = filter.JournalTypes.Any(y => y == x.JournalType);
});
}
示例8: LayoutPartPropertyPlansPageViewModel
public LayoutPartPropertyPlansPageViewModel(LayoutPartPlansViewModel layoutPartPlansViewModel)
{
_layoutPartPlansViewModel = layoutPartPlansViewModel;
_map = new Dictionary<Guid, PlanViewModel>();
Types = new ObservableCollection<LayoutPartPlansType>(Enum.GetValues(typeof(LayoutPartPlansType)).Cast<LayoutPartPlansType>());
Plans = new ObservableCollection<PlanViewModel>();
foreach (var plan in ClientManager.PlansConfiguration.Plans)
AddPlan(plan, null);
Plans.ForEach(item => item.IsChecked = false);
}
示例9: FilterTariffsViewModel
public FilterTariffsViewModel(Filter filter)
{
FilterTariffViewModel = new ObservableCollection<FilterTariffViewModel>();
DbCache.Tariffs.ForEach(x => FilterTariffViewModel.Add(new FilterTariffViewModel(x)));
FilterTariffViewModel.ForEach(x =>
{
if (filter.TariffUIDs.Contains(x.Tariff.UID))
x.IsChecked = true;
});
}
示例10: Populate
private void Populate()
{
DateTimeDescription = BuildDateTimeDescription(Meeting);
Attendees = new ObservableCollection<Attendee>(Meeting.Attendees);
Attendees.ForEach(a => a.OrganizerAddress = Meeting.Organizer?.EmailAddress.Address);
OnPropertyChanged(() => Attendees);
OnPropertyChanged(() => DateTimeDescription);
}
开发者ID:OfficeDev,项目名称:Interop-REST-Mail-Contacts-Calendar-Sample,代码行数:10,代码来源:DetailsPageViewModel.cs
示例11: FilterUsersViewModel
public FilterUsersViewModel(Filter filter)
{
FilterUserViewModel = new ObservableCollection<FilterUserViewModel>();
if (DbCache.GetAllUsers() != null)
{
DbCache.GetAllUsers().ForEach(x => FilterUserViewModel.Add(new FilterUserViewModel(x)));
FilterUserViewModel.ForEach(x =>
{
if (filter.UserUIDs.Contains(x.User.UID))
x.IsChecked = true;
});
}
}
示例12: CalculateFareRules
private void CalculateFareRules(int outside, double fee)
{
LimitHours = outside;
OnPropertyChanged(() => LimitHours);
OnPropertyChanged(() => InsideHoursTitle);
OnPropertyChanged(() => OutsideHoursTitle);
Fee = fee;
OnPropertyChanged(() => Fee);
FareTypeRules = new ObservableCollection<FareTypeRule>(FareTypeRule.GetFareTypeRules(SelectedBooking.FareType, fee, SelectedBooking.FareInfo.Currency.Symbol));
FareTypeRules.ForEach(r =>
{
r.InsideActivated += new EventHandler(OnOutsideRuleActivated);
r.OutsideActivated += new EventHandler(OnInsideRuleActivated);
});
OnPropertyChanged(() => FareTypeRules);
}
示例13: PopulateAttendees
private void PopulateAttendees()
{
Attendees = new ObservableCollection<Attendee>(Meeting.Attendees);
Attendees.ForEach(a => a.OrganizerAddress = Meeting.Organizer?.EmailAddress.Address);
OnPropertyChanged(() => Attendees);
UpdateAttendeesRelatedProperties();
}
示例14: LoadData
public async void LoadData()
{
IsBusy = true;
if (EventsFromDate == default(DateTime) && EventsToDate == default(DateTime))
{
EventsFromDate = DateTime.Now;
EventsToDate = DateTime.Now.Date.AddDays(31);
}
var weekStartDate = Properties.Settings.Default.WeeklyStartTime;
WeeklyStartTime = new TimeSpan(weekStartDate.Hour, weekStartDate.Minute, weekStartDate.Second);
var dayStartDate = Properties.Settings.Default.DailyStartTime;
DailyStartTime = new TimeSpan(dayStartDate.Hour, dayStartDate.Minute, dayStartDate.Second);
StartTimeForDayView = new TimeSpan(9, 0, 0);
await OnLoadEvents();
await OnLoadCalendarNotes();
UpdateEventsDataRange();
RefreshAppointments();
var types = await _eventsDataUnit.EventTypesRepository.GetAllAsync();
_allEventTypes = new List<EventTypeModel>(types.OrderBy(x => x.Name).Select(x => new EventTypeModel(x)));
CalencarEventTypesFilterItems =
new ObservableCollection<SelectableObject<string>>(
types.Select(x => new SelectableObject<string>(x.Name, true)));
CalencarEventTypesFilterItems.Insert(0, new SelectableObject<string>("Select All", false)); // insert on the top
CalencarEventTypesFilterItems.ForEach(x => x.PropertyChanged += SelectableEventTypeOnPropertyChanged);
ShowCalendarNotes = true;
var statusType = Convert.ToInt32(StatusType.ToDosStatus);
var reminderStatuses = await _eventsDataUnit.FollowUpStatusesRepository.GetAllAsync(todoStatus => todoStatus.StatusType == statusType);
ReminderStatuses = new ObservableCollection<FollowUpStatus>(reminderStatuses.OrderBy(x => x.NumberOfDays));
IsBusy = false;
}
示例15: TimelineViewModelBase
public TimelineViewModelBase(TimelineModelBase model)
{
this._model = model;
this._timeline = new ObservableCollection<StatusViewModel>();
DispatcherHolder.Enqueue(this.InitializeCollection, DispatcherPriority.Background);
this.CompositeDisposable.Add(
new EventListener<Action<bool>>(
h => model.InvalidationStateChanged += h,
h => model.InvalidationStateChanged -= h,
s => this.IsLoading = s));
this.CompositeDisposable.Add(() =>
{
if (_listener != null) _listener.Dispose();
});
this.CompositeDisposable.Add(
this.ListenPropertyChanged(() => this.CurrentAccounts)
.ObserveOnDispatcher()
.Select(_ => this.CurrentAccounts.ToArray())
.Subscribe(a => _timeline.ForEach(s => s.BindingAccounts = a)));
this.IsLoading = true;
this._model.InvalidateTimeline();
}