Hello
Suppose, there is a
List
of
MyObject
, and you've bound
MyObjectCollection
to the
DataGrid
List<mytype> MyObjectCollection
When you select a object then you want the
Next
and the
Previous
:
public MyType GetNextItem(object selectedObject, List<MyType> myObjectCollection)
{
int c = myObjectCollection.TakeWhile(o => o == selectedObject).Count() - 1;
int p = c - 1;
int n = c + 1;
return (myObjectCollection.Count() >= n + 1) ? myObjectCollection[n] : null;
}
public MyType GetPreviousItem(object selectedObject, List<MyType> myObjectCollection)
{
int c = myObjectCollection.TakeWhile(o => o == selectedObject).Count() - 1;
int p = c - 1;
int n = c + 1;
return (p >= 0) ? myObjectCollection[p] : null;
}