本文整理汇总了C#中ObservableCollection.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.IndexOf方法的具体用法?C# ObservableCollection.IndexOf怎么用?C# ObservableCollection.IndexOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.IndexOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateCollectionItem
public static void UpdateCollectionItem(ObservableCollection<string> collection,
string item,
string newValue)
{
if (collection != null)
GUIDispatcher.Invoke((Action)(() => { collection[collection.IndexOf(item)] = newValue; }));
}
示例2: Init
private void Init()
{
Musicses = new ObservableCollection<Musics>(Respostory.GetAllMusic());
InsertMusic = new RelayCommand(() =>
{
if (!Musicses.Contains(SelectMusic))
{
Musicses.Insert(0, SelectMusic);
Respostory.InsertMusic(SelectMusic);
}
});
LastMusic=new RelayCommand(() =>
{
_incuten = Musicses.IndexOf(SelectMusic);
if (-1 != _incuten)
{
SelectMusic = Musicses[_incuten - 1 >= 0 ? _incuten - 1 : 0];
}
});
NextMusic = new RelayCommand(() =>
{
_incuten = Musicses.IndexOf(SelectMusic);
if (-1 != _incuten)
{
SelectMusic = Musicses[_incuten + 1 < Musicses.Count ? _incuten + 1 : Musicses.Count-1];
}
});
}
示例3: setNewParent
public static void setNewParent(Guid itemId, Guid parentId, ObservableCollection<Todo> _Todos)
{
var thisItm = _Todos.FirstOrDefault(x=>x.Id==itemId);
if (parentId!= Guid.Empty)
{
var prnt = _Todos.FirstOrDefault(x => x.Id == parentId);
thisItm.ParentId = prnt.Id;
thisItm.Wbs = prnt.Wbs + ">";
int newIdx = _Todos.IndexOf(prnt)+1;
if (newIdx <= _Todos.Count)
{
_Todos.Remove(thisItm);
_Todos.Insert(newIdx, thisItm);
}
else
{
_Todos.Remove(thisItm);
_Todos.Add(thisItm);
}
}
else
{
thisItm.ParentId = Guid.Empty;
thisItm.Wbs = ">";
}
//_Todos[itemIndex] = thisItm;
updateChildren(thisItm, _Todos);
}
示例4: SettingsViewModel
public SettingsViewModel(IShell shell, ISettingsService settingsService, ICacheService cacheService, IBoard board, INewsService newsService) {
Shell = shell;
Board = board;
SettingsService = settingsService;
CacheService = cacheService;
AvailableLanguages = new ObservableCollection<CultureInfo>(
new[] { "en-US", "ru" }.Select(l => new CultureInfo(l)));
CurrentLanguage = CultureInfo.CurrentUICulture;
currentLanguageIndex = AvailableLanguages.IndexOf(CurrentLanguage);
Application.Current.Suspending += ApplyLanguage;
FontScale = SettingsService.FontScale;
AvailableThemes = new ObservableCollection<Theme>(Utils.GetEnumValues<Theme>());
CurrentThemeIndex = AvailableThemes.IndexOf(SettingsService.CurrentTheme);
AvailableRepliesDisplayModes =
new ObservableCollection<RepliesDisplayMode>(Utils.GetEnumValues<RepliesDisplayMode>());
Version = CreateVersion();
IsRedstoneBuild = Utils.IsRedstone();
SetupMediaDownloadFolder();
AvailableDomains = new ObservableCollection<string>(board.UrlService.AvailableDomains);
CurrentDomainIndex = SettingsService.CurrentDomain == "" ? 0 : AvailableDomains.IndexOf(SettingsService.CurrentDomain);
NewsService = newsService;
}
示例5: PhotoDetailViewModel
public PhotoDetailViewModel(ObservableCollection<PhotoContainerViewModel> photoViewModelList, PhotoContainerViewModel currentPhotoContainerViewModel)
: this()
{
_PhotoViewModelList = photoViewModelList;
CurrentIndex = photoViewModelList.IndexOf(currentPhotoContainerViewModel);
this.OnPropertyChanged(() => this.CurrentImage);
}
示例6: InitLoad
async public Task InitLoad()
{
List<lo_by_circle> los_in_Circle = JsonConvert.DeserializeObject<List<lo_by_circle>>(_serialized_list);
LOsInCircle = new ObservableCollection<lo_by_circle_wrapper>();
int i = 0;
foreach (var item in los_in_Circle)
{
LOsInCircle.Add(new lo_by_circle_wrapper { lo = item,stack =new stack_wrapper { IsLoaded = false } });
//Load images if its the selected LO
bool images = item.id == LOID;
//await LoadPages(i++, images);
await LoadPages2 (i++, images);
}
var selectedLOIndex = LOsInCircle.IndexOf(LOsInCircle.Where(lo => lo.lo.id == LOID).First());
await LoadBackgroundImages();
}
示例7: ClassChanged
private static void ClassChanged(object sender, NotifyCollectionChangedEventArgs args)
{
switch (args.Action) {
case NotifyCollectionChangedAction.Move:
M.ElementIndexChange((Class) sender, (Student) args.OldItems[0], args.OldStartingIndex);
Cache = new ObservableCollection<Student>((Class)sender);
break;
case NotifyCollectionChangedAction.Add:
case NotifyCollectionChangedAction.Replace:
case NotifyCollectionChangedAction.Remove:
if (args.OldItems != null) {
foreach (var student in args.OldItems.Cast<Student>()) {
M.ElementRemove((Class)sender, student, Cache.IndexOf(student));
student.PropertyChanging -= StudentChanging;
}
}
if (args.NewItems != null) {
foreach (var student in args.NewItems.Cast<Student>()) {
M.ElementAdd((Class) sender, student);
student.PropertyChanging += StudentChanging;
}
}
Cache = new ObservableCollection<Student>((Class)sender);
break;
default:
throw new NotSupportedException();
}
}
示例8: HandleCollectionChanges
private void HandleCollectionChanges(Client client, NotifyCollectionChangedEventArgs args, ObservableCollection<Interlocutor> actualCollection, ObservableCollection<object> nullCollection)
{
if (actualCollection.Count == 0)
{
nullCollection.Clear();
nullCollection.Add(new NullInterlocutor(client));
return;
}
var nullInterlocutor = nullCollection.OfType<NullInterlocutor>().FirstOrDefault();
if (nullInterlocutor != null)
{
nullCollection.Remove(nullInterlocutor);
}
if (args.OldItems != null)
{
foreach (var oldItem in args.OldItems)
{
nullCollection.Remove(oldItem);
}
}
if (args.NewItems != null)
{
foreach (var newItem in args.NewItems)
{
nullCollection.Insert(actualCollection.IndexOf((Interlocutor) newItem), newItem);
}
}
}
示例9: SalesDashboardLeadsViewModel
public SalesDashboardLeadsViewModel(Command pushTabbedLeadPageCommand, INavigation navigation = null)
: base(navigation)
{
_PushTabbedLeadPageCommand = pushTabbedLeadPageCommand;
_DataClient = DependencyService.Get<IDataClient>();
Leads = new ObservableCollection<Account>();
MessagingCenter.Subscribe<Account>(this, MessagingServiceConstants.SAVE_ACCOUNT, (account) =>
{
var index = Leads.IndexOf(account);
if (index >= 0)
{
Leads[index] = account;
}
else
{
Leads.Add(account);
}
Leads = new ObservableCollection<Account>(Leads.OrderBy(l => l.Company));
});
IsInitialized = false;
}
示例10: setWbs
public static void setWbs(ObservableCollection<Todo> items)
{
Action<Todo> SetPostion = null;
SetPostion = parent =>
{
//Recursively call the SetChildren method for each child.
var children = items.Where(x => x.ParentId == parent.Id).ToList();
for (int tmp = 0; tmp <= children.Count - 1; tmp++)
{
var child = children[tmp];
child.Wbs = parent.Wbs + ">";
int newIdx = items.IndexOf(parent) + 1;
int oldChildIdx = items.IndexOf(child);
if (newIdx < items.Count)
{
items.Remove(child);
if (newIdx>oldChildIdx) {
newIdx-=1;
}
items.Insert(newIdx, child);
}
else if (newIdx==items.Count)
{
items.Remove(child);
items.Add(child);
}
SetPostion(child);
}
};
//Initialize the hierarchical list to root level items
var roots = items.Where(x => x.ParentId == Guid.Empty).ToList();
for (int tmp = 0; tmp <= roots.Count - 1; tmp++)
{
var x=roots[tmp];
x.Wbs = ">";
SetPostion(x);
}
items.OrderBy(x => x.Wbs);
//return (items);
}
示例11: setCurrentViewOrder
private void setCurrentViewOrder(ObservableCollection<int> userOrder, ObservableCollection<int> curOrder)
{
var viewColumns = (listView.View as GridView).Columns;
// ユーザー指定のカラム順番に並び替える
for (var i = 0; i < Count; ++ i)
{
var ci = curOrder.IndexOf(userOrder[i]);
viewColumns.Move(ci, i);
curOrder.Move(ci, i); // カラム順番をViewから取得できないためここで追従
}
}
示例12: ReorderListBoxPage
public ReorderListBoxPage()
{
var brushes = new ObservableCollection<SolidColorBrush>(App.DemoColors.Select(c => c.ToCachedBrush()));
DataContext = brushes;
AddHandler(
ReorderListBox.ReorderRequestedEvent,
new EventHandler<ReorderEventArgs>(
delegate(object sender, ReorderEventArgs args) {
var reorderListBox = (ReorderListBox)args.OriginalSource;
var draggingBrush = (SolidColorBrush)reorderListBox.ItemContainerGenerator.ItemFromContainer(args.ItemContainer);
var toBrush = (SolidColorBrush)reorderListBox.ItemContainerGenerator.ItemFromContainer(args.ToContainer);
brushes.Move(brushes.IndexOf(draggingBrush), brushes.IndexOf(toBrush));
}));
InitializeComponent();
}
示例13: ContactsViewModel
public ContactsViewModel()
{
this.Title = "Contacts";
this.Icon = "list.png";
dataManager = DependencyService.Get<IDataManager>();
Contacts = new ObservableCollection<Contact>();
MessagingCenter.Subscribe<Contact>(this, "SaveContact", (contact) =>
{
var index = Contacts.IndexOf(contact);
if(index >= 0)
Contacts[index] = contact;
else
Contacts.Add(contact);
Contacts = new ObservableCollection<Contact>(from c in Contacts orderby c.LastName select c);
});
}
示例14: LeadsViewModel
public LeadsViewModel()
{
this.Title = "Leads";
this.Icon = "list.png";
dataManager = DependencyService.Get<IDataManager>();
Leads = new ObservableCollection<Account>();
MessagingCenter.Subscribe<Account>(this, "SaveAccount", (account) =>
{
var index = Leads.IndexOf(account);
if (index >= 0)
{
Leads[index] = account;
}
else
{
Leads.Add(account);
}
Leads = new ObservableCollection<Account>(from l in Leads orderby l.Company select l);
});
}
示例15: init
private void init()
{
isClosed = true;
beginedTasks = Task.GetMyBeginedTasks();
beginedTastsGrid.ItemsSource = beginedTasks;
allMyTasks = Task.GetTasks(new SQLiteWorker.QueryData
{
Where = "[email protected] and Percents<>@Percents",
Join = "",
Parameters = new List<SQLiteParameter>
{
new SQLiteParameter("GUID",
Settings.CurrentUser.GUID),
new SQLiteParameter("Percents", 100)
}
});
foreach (Task task in beginedTasks)
{
int index = -1;
foreach (Task allMyTask in allMyTasks)
{
if (allMyTask.GUID == task.GUID)
{
index = allMyTasks.IndexOf(allMyTask);
}
}
if (index != -1)
{
allMyTasks.RemoveAt(index);
}
}
allMyTasksGrid.ItemsSource = allMyTasks;
}