|
|
|
@ -108,7 +108,7 @@ namespace Avalonia.Controls.Repeaters |
|
|
|
_owner.ItemTemplateShim.RecycleElement(_owner, element); |
|
|
|
|
|
|
|
virtInfo.MoveOwnershipToElementFactory(); |
|
|
|
//_phaser.StopPhasing(element, virtInfo);
|
|
|
|
|
|
|
|
if (_lastFocusedElement == element) |
|
|
|
{ |
|
|
|
// Focused element is going away. Remove the tracked last focused element
|
|
|
|
@ -125,13 +125,9 @@ namespace Avalonia.Controls.Repeaters |
|
|
|
var focusCandidate = FindFocusCandidate(clearedIndex, focusedChild); |
|
|
|
if (focusCandidate != null) |
|
|
|
{ |
|
|
|
//var focusState = _lastFocusedElement?.FocusState ?? FocusState.Programmatic;
|
|
|
|
|
|
|
|
// If the last focused element has focus, use its focus state, if not use programmatic.
|
|
|
|
//focusState = focusState == FocusState.Unfocused ? FocusState.Programmatic : focusState;
|
|
|
|
focusCandidate.Focus(); |
|
|
|
|
|
|
|
_lastFocusedElement = focusedChild; |
|
|
|
|
|
|
|
// Add pin to hold the focused element.
|
|
|
|
UpdatePin(focusedChild, true /* addPin */); |
|
|
|
} |
|
|
|
@ -186,12 +182,12 @@ namespace Avalonia.Controls.Repeaters |
|
|
|
focusCandidate = nextElement as IControl; |
|
|
|
if (focusCandidate != null) |
|
|
|
{ |
|
|
|
////var firstFocus = FocusManager.FindFirstFocusableElement(nextElement);
|
|
|
|
var firstFocus = KeyboardNavigationHandler.GetNext(nextElement, NavigationDirection.First); |
|
|
|
|
|
|
|
////if (firstFocus != null)
|
|
|
|
////{
|
|
|
|
//// focusCandidate = firstFocus as IControl;
|
|
|
|
////}
|
|
|
|
if (firstFocus != null) |
|
|
|
{ |
|
|
|
focusCandidate = firstFocus as IControl; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -200,12 +196,12 @@ namespace Avalonia.Controls.Repeaters |
|
|
|
focusCandidate = previousElement as IControl; |
|
|
|
if (previousElement != null) |
|
|
|
{ |
|
|
|
////var lastFocus = FocusManager.FindLastFocusableElement(previousElement);
|
|
|
|
var lastFocus = KeyboardNavigationHandler.GetNext(previousElement, NavigationDirection.Last); |
|
|
|
|
|
|
|
////if (lastFocus != null)
|
|
|
|
////{
|
|
|
|
//// focusCandidate = lastFocus as IControl;
|
|
|
|
////}
|
|
|
|
if (lastFocus != null) |
|
|
|
{ |
|
|
|
focusCandidate = lastFocus as IControl; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -233,8 +229,6 @@ namespace Avalonia.Controls.Repeaters |
|
|
|
var elementInfo = _pinnedPool[i]; |
|
|
|
var virtInfo = elementInfo.VirtualizationInfo; |
|
|
|
|
|
|
|
//MUX_ASSERT(virtInfo.Owner() == ElementOwner.PinnedPool);
|
|
|
|
|
|
|
|
if (!virtInfo.IsPinned) |
|
|
|
{ |
|
|
|
_pinnedPool.RemoveAt(i); |
|
|
|
@ -471,16 +465,10 @@ namespace Avalonia.Controls.Repeaters |
|
|
|
IControl element = null; |
|
|
|
|
|
|
|
bool cachedFirstLastIndicesInvalid = _firstRealizedElementIndexHeldByLayout == FirstRealizedElementIndexDefault; |
|
|
|
//MUX_ASSERT(!cachedFirstLastIndicesInvalid || m_lastRealizedElementIndexHeldByLayout == LastRealizedElementIndexDefault);
|
|
|
|
|
|
|
|
bool isRequestedIndexInRealizedRange = (_firstRealizedElementIndexHeldByLayout <= index && index <= _lastRealizedElementIndexHeldByLayout); |
|
|
|
|
|
|
|
if (cachedFirstLastIndicesInvalid || isRequestedIndexInRealizedRange) |
|
|
|
{ |
|
|
|
// Both First and Last indices need to be valid or default.
|
|
|
|
//MUX_ASSERT((m_firstRealizedElementIndexHeldByLayout == FirstRealizedElementIndexDefault && m_lastRealizedElementIndexHeldByLayout == LastRealizedElementIndexDefault) ||
|
|
|
|
// (m_firstRealizedElementIndexHeldByLayout != FirstRealizedElementIndexDefault && m_lastRealizedElementIndexHeldByLayout != LastRealizedElementIndexDefault));
|
|
|
|
|
|
|
|
foreach (var child in _owner.Children) |
|
|
|
{ |
|
|
|
var virtInfo = ItemsRepeater.TryGetVirtualizationInfo(child); |
|
|
|
@ -572,27 +560,7 @@ namespace Avalonia.Controls.Repeaters |
|
|
|
} |
|
|
|
|
|
|
|
// Prepare the element
|
|
|
|
// If we are phasing, run phase 0 before setting DataContext. If phase 0 is not
|
|
|
|
// run before setting DataContext, when setting DataContext all the phases will be
|
|
|
|
// run in the OnDataContextChanged handler in code generated by the xaml compiler (code-gen).
|
|
|
|
var extension = false; ////CachedVisualTreeHelpers.GetDataTemplateComponent(element);
|
|
|
|
if (extension) |
|
|
|
{ |
|
|
|
////// Clear out old data.
|
|
|
|
////extension.Recycle();
|
|
|
|
////int nextPhase = VirtualizationInfo.PhaseReachedEnd;
|
|
|
|
////// Run Phase 0
|
|
|
|
////extension.ProcessBindings(data, index, 0 /* currentPhase */, nextPhase);
|
|
|
|
|
|
|
|
////// Setup phasing information, so that Phaser can pick up any pending phases left.
|
|
|
|
////// Update phase on virtInfo. Set data and templateComponent only if x:Phase was used.
|
|
|
|
////virtInfo.UpdatePhasingInfo(nextPhase, nextPhase > 0 ? data : null, nextPhase > 0 ? extension : null);
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
// Set data context only if no x:Bind was used. ie. No data template component on the root.
|
|
|
|
element.DataContext = data; |
|
|
|
} |
|
|
|
element.DataContext = data; |
|
|
|
|
|
|
|
virtInfo.MoveOwnershipToLayoutFromElementFactory( |
|
|
|
index, |
|
|
|
@ -613,9 +581,7 @@ namespace Avalonia.Controls.Repeaters |
|
|
|
children.Add(element); |
|
|
|
} |
|
|
|
|
|
|
|
////repeater.AnimationManager.OnElementPrepared(element);
|
|
|
|
repeater.OnElementPrepared(element, index); |
|
|
|
////_phaser.PhaseElement(element, virtInfo);
|
|
|
|
|
|
|
|
// Update realized indices
|
|
|
|
_firstRealizedElementIndexHeldByLayout = Math.Min(_firstRealizedElementIndexHeldByLayout, index); |
|
|
|
@ -635,25 +601,6 @@ namespace Avalonia.Controls.Repeaters |
|
|
|
return _isDataSourceStableResetPending; |
|
|
|
} |
|
|
|
|
|
|
|
private bool ClearElementToAnimator(IControl element, VirtualizationInfo virtInfo) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
////bool cleared = _owner.AnimationManager.ClearElement(element);
|
|
|
|
////if (cleared)
|
|
|
|
////{
|
|
|
|
//// int clearedIndex = virtInfo.Index;
|
|
|
|
//// virtInfo.MoveOwnershipToAnimator();
|
|
|
|
//// if (_lastFocusedElement == element)
|
|
|
|
//// {
|
|
|
|
//// // Focused element is going away. Remove the tracked last focused element
|
|
|
|
//// // and pick a reasonable next focus if we can find one within the layout
|
|
|
|
//// // realized elements.
|
|
|
|
//// MoveFocusFromClearedIndex(clearedIndex);
|
|
|
|
//// }
|
|
|
|
////}
|
|
|
|
////return cleared;
|
|
|
|
} |
|
|
|
|
|
|
|
private bool ClearElementToPinnedPool(IControl element, VirtualizationInfo virtInfo, bool isClearedDueToCollectionChange) |
|
|
|
{ |
|
|
|
if (_isDataSourceStableResetPending) |
|
|
|
|