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

Xamarin Forms Listview set focus to entry on selected row event

$
0
0

I am using the ListView and in each cell I have a label and an entry to the right side. When I click on the entry box the keyboard will show up but if I click on the row without clicking on the entry box the keyboard does not. How can I cause the entry to be focused when its row is selected?

`<?xml version="1.0" encoding="UTF-8"?>

<ContentPage.ToolbarItems>
    <ToolbarItem Text="Scanner" Icon="camera.png">
    </ToolbarItem>

    <ToolbarItem Text="Notes" Icon="notes.png" >
    </ToolbarItem>
</ContentPage.ToolbarItems>


<ScrollView>
    <StackLayout Padding="20,20,20,0">
            <Picker Title="Location" HorizontalOptions="FillAndExpand" Items="NuseedDataManager.getWarehouses()"/>

            <StackLayout Orientation="Horizontal" Padding="0,20,0,20">
                <Label Text="Show All" HorizontalOptions="FillAndExpand" />
                <Switch IsToggled="true"  HeightRequest="50" WidthRequest="250"/>
            </StackLayout>

            <ListView x:Name="SkuListView" RowHeight="60">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>

                            <StackLayout Orientation="Horizontal" BackgroundColor="{Binding BackgroundColor}">
                                <Label Text="TITLE\nawesome1awesome1awesome1awesome1awesome1awesome1awesome1awesome1awesome1awesome1awesome1awesome1" HorizontalOptions="FillAndExpand" FontSize="12"/>
                                <Entry Text="{Binding CountText}" WidthRequest="70" Keyboard="Numeric" IsFocused="{Binding IsEntryFocused}" />
                            </StackLayout>

                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

            <StackLayout Padding="0,20,0,20">
                <Button Text="Verify" />
            </StackLayout>
    </StackLayout>
</ScrollView>

`

`namespace Sample7
{
public partial class StartPage : ContentPage
{
ObservableCollection skus ;
public StartPage ()
{
InitializeComponent ();

        skus = new ObservableCollection<Cell>();


        for (int i = 0; i < 30; i++) {

            if (i < 10) {
                skus.Add(new Cell(){
                    BackgroundColor = Color.Aqua,
                    CountText = "1"
                });
            } else {

                skus.Add (new Cell () {
                    BackgroundColor = Color.Red,
                    CountText = "1"
                });

            }
        }

        SkuListView.ItemsSource = skus;

        SkuListView.HeightRequest = SkuListView.RowHeight* skus.Count ()+40;

        SkuListView.ItemSelected += (sender, e) => {
            Cell c = (Cell)e.SelectedItem;

            c.IsEntryFocused = true;
            c.BackgroundColor = Color.Olive;
            c.CountText = "45";

        };
    }
}

}`


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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