I have a ListView with an ItemTemplate & ViewCell defined in the xaml. My ViewCell contains a grid that has numerous Entry controls. When an Entry is clicked it gains focus, causing the keyboard to open. When the keyboard opens though the selected Entry loses focus and depending on the Android version it either selects the 1st entry in the grid at the top left ( Android 8.1 emulator) or just loses focus and selects nothing at all (9.0 Pixel 3XL).
Through various testing/hack attempts to fix this I've found that what is happening is that when the keyboard opens the ViewCell is recyling and the Entry that was previously selected is not actually in the UI anymore. I have tested this scenario using a very simple ListView with only 2 Entry controls in the ViewCell and nothing else and the same behavior is observed. If I select the 2nd Entry (bottom of StackLayout) it either loses focus and focuses on the 1st one when the keyboard opens, or loses focus completely (depends on Android version).
I feel that I must be missing something or doing something wrong, because this seems like an extremely common scenario and I cannot imagine that this is a bug no one has encountered yet. Below is the XAML for my ListView. This is my 1st post, so I apologize if I have done anything incorrectly.
<ListView x:Name="SetsListView" ItemsSource="{Binding Lifts}"
VerticalOptions="FillAndExpand"
HasUnevenRows="true"
CachingStrategy="RetainElement"
ItemSelected="SetsListView_ItemSelected"
BackgroundColor="#383838">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="2">
<Frame HasShadow="True" OutlineColor="#49C3CB">
<StackLayout>
<Label Text="{Binding LiftName}" FontAttributes="Bold" FontSize="Large" TextColor="Black"/>
<Grid ColumnSpacing="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="{Binding GridHeight[0]}"/>
<RowDefinition Height="{Binding GridHeight[1]}"/>
<RowDefinition Height="{Binding GridHeight[2]}"/>
<RowDefinition Height="{Binding GridHeight[3]}"/>
<RowDefinition Height="{Binding GridHeight[4]}"/>
<RowDefinition Height="{Binding GridHeight[5]}"/>
</Grid.RowDefinitions>
<Label Text="#" HorizontalTextAlignment="Center" FontAttributes="Bold" TextColor="Black" Grid.Row="0" Grid.Column="0"/>
<Label Text="Reps" HorizontalTextAlignment="Center" FontAttributes="Bold" TextColor="Black" Grid.Row="0" Grid.Column="1"/>
<Label Text="Weight" HorizontalTextAlignment="Center" FontAttributes="Bold" TextColor="Black" Grid.Row="0" Grid.Column="2"/>
<Label Text="RPE" HorizontalTextAlignment="Center" FontAttributes="Bold" TextColor="Black" Grid.Row="0" Grid.Column="3"/>
<Label Text="1RM" HorizontalTextAlignment="Center" FontAttributes="Bold" TextColor="Black" Grid.Row="0" Grid.Column="4"/>
<Label Text="✔" HorizontalTextAlignment="Center" FontAttributes="Bold" TextColor="Black" Grid.Row="0" Grid.Column="5"/>
<Label Text="{Binding Sets[0].SetNumber}" VerticalTextAlignment="Center" TextColor="Black" Grid.Row="1" Grid.Column="0"/>
<Entry Text="{Binding Sets[0].RepsCompleted}" TextColor="Black" Keyboard="Numeric" Placeholder="{Binding Sets[0].RepGoal}" PlaceholderColor="LightGray" HorizontalTextAlignment="Center" Grid.Row="1" Grid.Column="1"/>
<Entry Text="{Binding Sets[0].WeightCompleted}" TextColor="Black" Keyboard="Numeric" Placeholder="{Binding Sets[0].RecommendedWeight}" PlaceholderColor="LightGray" HorizontalTextAlignment="Center" Grid.Row="1" Grid.Column="2"/>
<Entry Text="{Binding Sets[0].RPE}" IsVisible="{Binding Sets[0].IsRPEVisible}" TextColor="Black" Keyboard="Numeric" HorizontalTextAlignment="Center" Grid.Row="1" Grid.Column="3"/>
<Label Text="{Binding Sets[0].Estimated1RM}" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" TextColor="Black" Grid.Row="1" Grid.Column="4"/>
<Switch IsEnabled="{Binding Sets[0].CanComplete}" IsToggled="{Binding Sets[0].IsComplete}" HorizontalOptions="CenterAndExpand" Grid.Row="1" Grid.Column="5" />
<Label Text="{Binding Sets[1].SetNumber}" VerticalTextAlignment="Center" TextColor="Black" Grid.Row="2" Grid.Column="0"/>
<Entry Text="{Binding Sets[1].RepsCompleted}" TextColor="Black" Keyboard="Numeric" Placeholder="{Binding Sets[1].RepGoal}" PlaceholderColor="LightGray" HorizontalTextAlignment="Center" Grid.Row="2" Grid.Column="1"/>
<Entry Text="{Binding Sets[1].WeightCompleted}" TextColor="Black" Keyboard="Numeric" Placeholder="{Binding Sets[1].RecommendedWeight}" PlaceholderColor="LightGray" HorizontalTextAlignment="Center" Grid.Row="2" Grid.Column="2"/>
<Entry Text="{Binding Sets[1].RPE}" IsVisible="{Binding Sets[1].IsRPEVisible}" TextColor="Black" Keyboard="Numeric" HorizontalTextAlignment="Center" Grid.Row="2" Grid.Column="3"/>
<Label Text="{Binding Sets[1].Estimated1RM}" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" TextColor="Black" Grid.Row="2" Grid.Column="4"/>
<Switch IsEnabled="{Binding Sets[1].CanComplete}" IsToggled="{Binding Sets[1].IsComplete}" HorizontalOptions="CenterAndExpand" Grid.Row="2" Grid.Column="5" />
<Label Text="{Binding Sets[2].SetNumber}" VerticalTextAlignment="Center" TextColor="Black" Grid.Row="3" Grid.Column="0"/>
<Entry Text="{Binding Sets[2].RepsCompleted}" TextColor="Black" Keyboard="Numeric" Placeholder="{Binding Sets[2].RepGoal}" PlaceholderColor="LightGray" HorizontalTextAlignment="Center" Grid.Row="3" Grid.Column="1"/>
<Entry Text="{Binding Sets[2].WeightCompleted}" TextColor="Black" Keyboard="Numeric" Placeholder="{Binding Sets[2].RecommendedWeight}" PlaceholderColor="LightGray" HorizontalTextAlignment="Center" Grid.Row="3" Grid.Column="2"/>
<Entry Text="{Binding Sets[2].RPE}" IsVisible="{Binding Sets[2].IsRPEVisible}" TextColor="Black" Keyboard="Numeric" HorizontalTextAlignment="Center" Grid.Row="3" Grid.Column="3"/>
<Label Text="{Binding Sets[2].Estimated1RM}" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" TextColor="Black" Grid.Row="3" Grid.Column="4"/>
<Switch IsEnabled="{Binding Sets[2].CanComplete}" IsToggled="{Binding Sets[2].IsComplete}" HorizontalOptions="CenterAndExpand" Grid.Row="3" Grid.Column="5" />
<Label Text="{Binding Sets[3].SetNumber}" VerticalTextAlignment="Center" TextColor="Black" Grid.Row="4" Grid.Column="0"/>
<Entry Text="{Binding Sets[3].RepsCompleted}" TextColor="Black" Keyboard="Numeric" Placeholder="{Binding Sets[3].RepGoal}" PlaceholderColor="LightGray" HorizontalTextAlignment="Center" Grid.Row="4" Grid.Column="1"/>
<Entry Text="{Binding Sets[3].WeightCompleted}" TextColor="Black" Keyboard="Numeric" Placeholder="{Binding Sets[3].RecommendedWeight}" PlaceholderColor="LightGray" HorizontalTextAlignment="Center" Grid.Row="4" Grid.Column="2"/>
<Entry Text="{Binding Sets[3].RPE}" IsVisible="{Binding Sets[3].IsRPEVisible}" TextColor="Black" Keyboard="Numeric" HorizontalTextAlignment="Center" Grid.Row="4" Grid.Column="3"/>
<Label Text="{Binding Sets[3].Estimated1RM}" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" TextColor="Black" Grid.Row="4" Grid.Column="4"/>
<Switch IsEnabled="{Binding Sets[3].CanComplete}" IsToggled="{Binding Sets[3].IsComplete}" HorizontalOptions="CenterAndExpand" Grid.Row="4" Grid.Column="5" />
<Label Text="{Binding Sets[4].SetNumber}" VerticalTextAlignment="Center" TextColor="Black" Grid.Row="5" Grid.Column="0"/>
<Entry Text="{Binding Sets[4].RepsCompleted}" TextColor="Black" Keyboard="Numeric" Placeholder="{Binding Sets[4].RepGoal}" PlaceholderColor="LightGray" HorizontalTextAlignment="Center" Grid.Row="5" Grid.Column="1"/>
<Entry Text="{Binding Sets[4].WeightCompleted}" TextColor="Black" Keyboard="Numeric" Placeholder="{Binding Sets[4].RecommendedWeight}" PlaceholderColor="LightGray" HorizontalTextAlignment="Center" Grid.Row="5" Grid.Column="2"/>
<Entry Text="{Binding Sets[4].RPE}" IsVisible="{Binding Sets[4].IsRPEVisible}" TextColor="Black" Keyboard="Numeric" HorizontalTextAlignment="Center" Grid.Row="5" Grid.Column="3"/>
<Label Text="{Binding Sets[4].Estimated1RM}" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" TextColor="Black" Grid.Row="5" Grid.Column="4"/>
<Switch IsEnabled="{Binding Sets[4].CanComplete}" IsToggled="{Binding Sets[4].IsComplete}" HorizontalOptions="CenterAndExpand" Grid.Row="5" Grid.Column="5" />
<Label Text="{Binding Sets[5].SetNumber}" VerticalTextAlignment="Center" TextColor="Black" Grid.Row="6" Grid.Column="0"/>
<Entry Text="{Binding Sets[5].RepsCompleted}" TextColor="Black" Keyboard="Numeric" Placeholder="{Binding Sets[5].RepGoal}" PlaceholderColor="LightGray" HorizontalTextAlignment="Center" Grid.Row="6" Grid.Column="1"/>
<Entry Text="{Binding Sets[5].WeightCompleted}" TextColor="Black" Keyboard="Numeric" Placeholder="{Binding Sets[5].RecommendedWeight}" PlaceholderColor="LightGray" HorizontalTextAlignment="Center" Grid.Row="6" Grid.Column="2"/>
<Entry Text="{Binding Sets[5].RPE}" IsVisible="{Binding Sets[5].IsRPEVisible}" TextColor="Black" Keyboard="Numeric" HorizontalTextAlignment="Center" Grid.Row="6" Grid.Column="3"/>
<Label Text="{Binding Sets[5].Estimated1RM}" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" TextColor="Black" Grid.Row="6" Grid.Column="4"/>
<Switch IsEnabled="{Binding Sets[5].CanComplete}" IsToggled="{Binding Sets[5].IsComplete}" HorizontalOptions="CenterAndExpand" Grid.Row="6" Grid.Column="5" />
</Grid>
</StackLayout>
</Frame>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>