In WPF I can specify that a control container is a Focus Scope and that tab navigation should cycle through the controls (i.e. when I tab out of the final control, focus will return to the first):
<Border FocusManager.IsFocusScope="True" KeyboardNavigation.TabNavigation="Cycle">
<ItemsControl ItemsSource="{Binding}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBox x:Name="Editor" Text="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Border>
What I am trying to do is to detect when focus leaves the final field. Without knowing precisely the number of controls within the focus scope, does anyone know if this is possible?