按下后,屏幕键盘上的返回按钮列表视图隐藏在iOS屏幕上。相同的代码在Android上运行完美。我创建了30秒的视频,可以帮助您理解问题。代码文件和视频可以从这里下载https://drive.google.com/drive/folders/1Q4O1KexIHvrCX79AR3CesRXJRWM1o2JR?usp=sharing
<ListView x:Name="listViewOrder" ItemTapped="OnActivitySelected" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Frame HasShadow="True" OutlineColor="Silver" Padding="3">
<Grid BackgroundColor="{Binding RowColour}" ColumnSpacing="2" Padding="2">
<StackLayout Orientation="Horizontal" HeightRequest="35" BackgroundColor="{Binding RowColour}" Padding="10">
<StackLayout Spacing="0" BackgroundColor="{Binding RowColour}" Orientation="Horizontal" HorizontalOptions="Start">
<Label FontSize="Medium" TextColor="#707070" Text="{Binding GFIELD3}" HorizontalOptions="StartAndExpand" VerticalOptions="Center"/>
</StackLayout>
<StackLayout Spacing="0" BackgroundColor="{Binding RowColour}" Orientation="Horizontal" HorizontalOptions="EndAndExpand">
<Image Aspect="AspectFit" Source = "{Binding ImageStatus}" HorizontalOptions="StartAndExpand" VerticalOptions="Center" HeightRequest = "20" WidthRequest="20" />
</StackLayout>
</StackLayout>
</Grid>
</Frame>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<StackLayout x:Name="layoutForBluetooth" HeightRequest="200" Padding="5, 5, 5, 5" BackgroundColor="#5DCBEE" Orientation="Horizontal" HorizontalOptions="FillAndExpand">
<Frame Padding="5,5,5,5" HorizontalOptions="FillAndExpand" OutlineColor="Black" HasShadow="True">
<Grid>
<Label Text="Scan Your Barcode" x:Name="lblDriverNumber" TextColor="Black" FontSize="Medium" HorizontalOptions="FillAndExpand" Margin="0,10" />
<Entry x:Name="txtentry" FontSize="Medium" TextColor="Black" WidthRequest="400" HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand" />
</Grid>
</Frame>
async void Txtentry_Completed(object sender, EventArgs e)
{
BiendListview(orderID);
}
public void BiendListview(int OID)
{
try
{
List<GenericFields> GN = new List<GenericFields>();
GN = GetDeliveryOrderItems(OID);
if (GN != null)
{
// listViewOrder.BeginRefresh();
listViewOrder.ItemsSource = GN;
// listViewOrder.EndRefresh();
}
}
catch (Exception ex)
{
}
}
请设置断点来调试GN的值。从您的代码:
if (GN != null)
{
// listViewOrder.BeginRefresh();
listViewOrder.ItemsSource = GN;
// listViewOrder.EndRefresh();
}
这个if语句总是正确的,因为你已经用GN
构造了List<GenericFields> GN = new List<GenericFields>();
。它永远不会为空。
您可以尝试将其修改为:
if (GN.Count != 0)
{
// listViewOrder.BeginRefresh();
listViewOrder.ItemsSource = GN;
// listViewOrder.EndRefresh();
}