Skip to content

Commit d01bbd7

Browse files
committed
use bool flag for ListViewBase
1 parent fb9738d commit d01bbd7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Microsoft.Toolkit.Uwp.UI.Behaviors/Focus/FocusBehavior.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private void ApplyFocus()
110110
}
111111

112112
var focusedControlIndex = -1;
113-
var listViewBaseControls = 0;
113+
var hasListViewBaseControl = false;
114114
for (var i = 0; i < Targets.Count; i++)
115115
{
116116
var control = Targets[i].Control;
@@ -132,7 +132,7 @@ private void ApplyFocus()
132132
// The list may not have any item yet, we wait until the first item is rendered.
133133
listViewBase.ContainerContentChanging -= OnContainerContentChanging;
134134
listViewBase.ContainerContentChanging += OnContainerContentChanging;
135-
listViewBaseControls++;
135+
hasListViewBaseControl = true;
136136
}
137137
}
138138
else
@@ -142,7 +142,7 @@ private void ApplyFocus()
142142
}
143143
}
144144

145-
if (focusedControlIndex == 0 || (listViewBaseControls == 0 && Targets.All(t => t.Control?.IsLoaded == true)))
145+
if (focusedControlIndex == 0 || (!hasListViewBaseControl && Targets.All(t => t.Control?.IsLoaded == true)))
146146
{
147147
// The first control has received the focus or all the control are loaded and none can take the focus: we stop.
148148
Stop();

0 commit comments

Comments
 (0)