private void RecycleCandidate( UIElement container ) { int realizedIndex; if( !m_oldLayoutedContainers.TryGetValue( container, out realizedIndex ) ) return; m_oldLayoutedContainers.Remove( container ); var containerInfo = new LayoutedContainerInfo( realizedIndex, container ); // Keep the focused container active by putting it in the layouted containers collection. if( container == m_focusedContainer ) { m_newLayoutedContainers.Add( containerInfo ); } else { m_itemsHost.RecycleContainer( m_generator, containerInfo ); } }
private void RecycleContainer( ICustomItemContainerGenerator generator, LayoutedContainerInfo containerInfo ) { Debug.Assert( containerInfo != null ); var index = containerInfo.RealizedIndex; if( ( generator != null ) && ( index >= 0 ) ) { try { var position = generator.GeneratorPositionFromIndex( index ); generator.Remove( position, 1 ); } catch { Debug.Fail( "Unable to remove container for containerIndex " + index ); } } this.ClearContainer( containerInfo.Container ); }
protected LayoutedContainerInfo CreateContainer( int realizedIndex ) { if( ( realizedIndex < 0 ) || ( realizedIndex >= m_itemCount ) ) return null; this.RecycleCandidates( realizedIndex ); var position = m_generator.GeneratorPositionFromIndex( realizedIndex ); using( m_generator.StartAt( position, GeneratorDirection.Forward, true ) ) { var container = m_itemsHost.GenerateContainer( m_generator, realizedIndex, m_forceMeasure ); if( container == null ) return null; m_remainingViewportHeight -= container.DesiredSize.Height; m_oldLayoutedContainers.Remove( container ); var containerInfo = new LayoutedContainerInfo( realizedIndex, container ); m_newLayoutedContainers.Add( containerInfo ); return containerInfo; } }