当我尝试重新绑定Listview UI时,空白意味着没有显示页面。这个问题只发生在我在iOS上测试我的项目时,在android中它运行得很好。我的代码页是一个文本完成事件,当我第一次运行我的代码时,UI看起来很完美。但是当我在文本框中写入一些文本并按下输入按钮UI隐藏在屏幕上并且屏幕上没有显示任何内容。
我的页面XAML与.cs页面可以从Google Drive下载我的代码部分如下: -
<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">
<Label FontSize="Medium" TextColor="#707070" Text="{Binding OrderNum}" 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>
绑定列表视图: -
async void Txtentry_Completed(object sender, EventArgs e)
{
try
{
string s = ((Entry)sender).Text;
if(s.Trim() != string.Empty)
{
BindListview(orderID);
}
}
catch
{
}
}
public void BindListview(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)
{
error(ex.Message, Convert.ToString(ex.InnerException), ex.Source, ex.StackTrace);
}
}
public List<GenericFields> GetDeliveryOrderItems(int _OrderID)
{
//DateTime dat = DateTime.Now.Date;
//long tick = dat.Ticks;
List<GenericFields> GN = new List<GenericFields>();
try
{
GN = App.DAUtil.GetInboundOrderItems(_OrderID);
if (GN.Count > 0)
{
bool _chkStatus = true;
for (int i = 0; i < GN.Count(); i++)
{
// if (GN[i].Inboundprocessed == "1")
if (Convert.ToString(GN[i].GFIELD6) != "")
{
GN[i].ImageStatus = "ok1.png";
GN[i].RowColour = "#D3D3D3";
}
else
{
GN[i].ImageStatus = "cancel1.png";
GN[i].RowColour = "#ffffff";
_chkStatus = false;
}
}
}
}
catch (Exception ex)
{
error(ex.Message, Convert.ToString(ex.InnerException), ex.Source, ex.StackTrace);
}
//
return GN;
}