【问题标题】:Xamarin Forms Listview's Entry conflict with custom pickerXamarin Forms Listview 的条目与自定义选择器冲突
【发布时间】:2018-10-23 17:10:12
【问题描述】:

我的应用程序发生了一个非常奇怪的问题,我有一个自定义选择器,列表视图的标题中有一个图像、XAML 和 C# 代码:

<controls:CustomPicker Image="arrow" x:Name="filter1" SelectedIndexChanged="filter1_SelectedIndexChanged" HorizontalOptions="FillAndExpand" BackgroundColor="Transparent" TextColor="Black" Title="Category">
                                <controls:CustomPicker.Margin>
                                    <OnIdiom Phone="8,8,8,8" Tablet="12,12,12,12"/>
                                </controls:CustomPicker.Margin>
                                <controls:CustomPicker.FontSize>
                                    <OnIdiom Phone="16" Tablet="24"/>
                                </controls:CustomPicker.FontSize>
                            </controls:CustomPicker>

 public async void filter1_SelectedIndexChanged(object sender, EventArgs e)
        {
            index = 0;
            var selected = filter1.Items[filter1.SelectedIndex];
            for (int i = 0; i < mylist.Count; i++)
            {
                if (mylist[i].description == selected && selected != null && selected != "")
                {
                    await GetItemsCategorized(mylist[i].code, index, searching.Text);
                }
            }
        }

以及在视单元中具有条目的列表视图、XAML 和 C# 代码:

<StackLayout Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                                                    <Entry Keyboard="Numeric" HorizontalOptions="EndAndExpand" TextChanged="Entry_TextChanged"  WidthRequest="40">
                                                        <Entry.Behaviors>
                                                            <controls:NumericValidationBehavior/>
                                                        </Entry.Behaviors>
                                                    </Entry>
                                                </StackLayout> 




  private void Entry_TextChanged(object sender, TextChangedEventArgs e)
    {
        var entry = sender as Entry;
        var product = entry.BindingContext as Sales_Order_Items;
        if (e.NewTextValue != null && e.NewTextValue != "" && !e.NewTextValue.Contains("-") && !e.NewTextValue.Contains("."))
            product.requested_quantity = int.Parse(e.NewTextValue.ToString());
        else
            product.requested_quantity = 0;
    }

当我专注于每个视图单元上的条目时,当列表视图显示在 Android 上时,事情就在 android 上,选择器通过键盘启用并且键盘消失了!!!!在 iOS 上运行良好:

focusing on entry-android

focused on entry-android

focused on entry-ios

知道为什么会这样吗?!!

【问题讨论】:

    标签: c# android listview xamarin.forms


    【解决方案1】:

    自定义选择器放在列表视图的标题中,我把它放在列表视图之外,应用程序现在可以正常工作了!!

    【讨论】:

      猜你喜欢
      • 2021-09-04
      • 2016-09-03
      • 1970-01-01
      • 2015-06-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-25
      • 1970-01-01
      • 2020-12-10
      相关资源
      最近更新 更多