@@ -216,7 +216,7 @@ public void ClearElementToElementFactory(UIElement element)
216
216
void MoveFocusFromClearedIndex ( int clearedIndex )
217
217
{
218
218
UIElement focusedChild = null ;
219
- var focusCandidate = FindFocusCandidate ( clearedIndex , focusedChild ) ;
219
+ var focusCandidate = FindFocusCandidate ( clearedIndex , out focusedChild ) ;
220
220
if ( focusCandidate != null )
221
221
{
222
222
FocusState focusState = FocusState . Programmatic ;
@@ -240,7 +240,7 @@ void MoveFocusFromClearedIndex(int clearedIndex)
240
240
}
241
241
}
242
242
243
- Control FindFocusCandidate ( int clearedIndex , UIElement focusedChild )
243
+ Control FindFocusCandidate ( int clearedIndex , out UIElement focusedChild )
244
244
{
245
245
// Walk through all the children and find elements with index before and after the cleared index.
246
246
// Note that during a delete the next element would now have the same index.
@@ -280,9 +280,10 @@ Control FindFocusCandidate(int clearedIndex, UIElement focusedChild)
280
280
// Find the next element if one exists, if not use the previous element.
281
281
// If the container itself is not focusable, find a descendent that is.
282
282
Control focusCandidate = null ;
283
+ focusedChild = null ;
283
284
if ( nextElement != null )
284
285
{
285
- // focusedChild = nextElement as UIElement;
286
+ focusedChild = nextElement as UIElement ;
286
287
focusCandidate = nextElement as Control ;
287
288
if ( focusCandidate == null )
288
289
{
@@ -294,20 +295,19 @@ Control FindFocusCandidate(int clearedIndex, UIElement focusedChild)
294
295
}
295
296
}
296
297
297
- // TODO UNO: Case declared as useless by intellisense
298
- //if (focusCandidate == null && previousElement != null)
299
- //{
300
- // focusedChild = previousElement as UIElement;
301
- // focusCandidate = previousElement as Control;
302
- // if (previousElement == null)
303
- // {
304
- // var lastFocus = FocusManager.FindLastFocusableElement(previousElement);
305
- // if (lastFocus != null)
306
- // {
307
- // focusCandidate = lastFocus as Control;
308
- // }
309
- // }
310
- //}
298
+ if ( focusCandidate == null && previousElement != null )
299
+ {
300
+ focusedChild = previousElement as UIElement ;
301
+ focusCandidate = previousElement as Control ;
302
+ if ( previousElement == null )
303
+ {
304
+ var lastFocus = FocusManager . FindLastFocusableElement ( previousElement ) ;
305
+ if ( lastFocus != null )
306
+ {
307
+ focusCandidate = lastFocus as Control ;
308
+ }
309
+ }
310
+ }
311
311
312
312
return focusCandidate ;
313
313
}
0 commit comments