Row GetListViewItem(int index, DataGridControl lvObject) { //if (lvObject.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated) // return null; //return lvObject.ItemContainerGenerator.ContainerFromIndex(index) as ListViewItem; return lvObject.GetContainerFromIndex(index) as Row; }
private static FrameworkElement ProcessFirstVisibleContainer( DataGridControl gridControl, double offset, double viewportSize, double opposedOffset, double opposedViewportSize, Orientation panelOrientation ) { FrameworkElement retval = null; // Only needed if the DataGridControl contains items if( ( gridControl != null ) && ( gridControl.Items.Count > 0 ) ) { bool qualifyingContainerFound = false; //retrieve the last object index according to item scrolling axis (this covers both the "Vertical and None" primary axis cases... //as well as default if no other row matches the PrimaryAxis criteria) int runningIndex = ( int )( offset ); //cycle for as long as a qualifying container is not found. while( !qualifyingContainerFound ) { retval = gridControl.GetContainerFromIndex( runningIndex ) as FrameworkElement; //will be reverted back if the container does not match a particular condition. if( retval != null ) { qualifyingContainerFound = ScrollViewerHelper.IsContainerQualifying( retval, gridControl, offset, viewportSize, opposedOffset, opposedViewportSize, panelOrientation ); } //under all circumstances, if I am back at the end of the viewport ( last item visible), then have it qualify. if( runningIndex == ( offset + viewportSize - 1 ) ) qualifyingContainerFound = true; runningIndex++; } } return retval; }