Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Programmatically focus on next entry in Listview (Android/IOS/UWP, Xamarin.Forms)

$
0
0

I have the following xaml:

        <ListView x:Name="ListViewItemPage" ItemTapped="ListView_OnItemTapped" >
            <ListView.ItemTemplate>
                <DataTemplate x:Name="DataTemplate">
                    <ViewCell>
                        <RelativeLayout x:Name="RelativeLayout" >
                            <Label x:Name="DescriptionLabel" Text="{Binding Description}" RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Y, Factor=0, Constant=15}" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=X, Factor=0, Constant=15}" />
                            <Entry x:Name="ValueEntry" WidthRequest="85" Keyboard="Text" HorizontalTextAlignment="Start" FontSize="19" HorizontalOptions="Center" VerticalOptions="Center" Text="{Binding Value, Mode=TwoWay, Converter={StaticResource FloatValueConverter}}" Focused="ValueEntry_OnFocused" Unfocused="ValueEntry_OnUnfocused" 
                                       RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Y, Factor=0, Constant=10}" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant={StaticResource ConstantMultiPlatform}}" >
                                <Entry.HeightRequest>
                                    <OnPlatform x:TypeArguments="x:Double">
                                        <On Platform="iOS" Value="28"></On>
                                        <On Platform="Android" Value="42"></On>
                                        <On Platform="UWP" Value="32"></On>
                                    </OnPlatform>
                                </Entry.HeightRequest>
                            </Entry>
                        </RelativeLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

And in code, i'm using this method. On Android/IOS it's working well, but on UWP it doesn't work.

public async Task GetFocusOnNextEntry()
    {
        var focused = (CollectionItemValues)focusedEntry.BindingContext;

        var index = _obserColItemValues.IndexOf(focused);

        var nextEntry = (Entry)ListViewItemPage.TemplatedItems[index + 1].LogicalChildren[0].LogicalChildren[1];
        nextEntry.Focus();
    }

How do I focus in UWP Xamarin Forms App (Portable) from selected entry to the next entry in Listview?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>