Below is my query- when a new element comes to the StoriesCollection
RangeObservableCollection
.
I'm moving the elements in the collection based on below logic:
(pinned entries should be fixed in the grid so I am checking if the new entry is pinned/unpinned, if it is unpinned then I am moving the other elements in the collection by one place each to fit the new element).
please help to optimize it with LINQ.
private void AdjustPinnedStories()
{
for (int i = 1; i < StoriesCollection.Count; i++)
{
if (StoriesCollection[i].IsPinned)
{
if (!StoriesCollection[i - 1].IsPinned)
{
StoriesCollection.Move(i, i - 1);
}
}
}
}