Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何删除Xamarin.Forms TableView并重新创建它而不使应用程序崩溃_C#_Xamarin_Xamarin.forms - Fatal编程技术网

C# 如何删除Xamarin.Forms TableView并重新创建它而不使应用程序崩溃

C# 如何删除Xamarin.Forms TableView并重新创建它而不使应用程序崩溃,c#,xamarin,xamarin.forms,C#,Xamarin,Xamarin.forms,我在Xamarin.Forms 1.4.2中有一个StackLayout,我正试图从后面的代码创建一个表视图,然后为了测试,我在StackLayout中有一个按钮来重新创建表视图 如果我使用标准的TextCell,那么我可以根据自己的意愿多次重新创建TableView,而不会导致应用程序崩溃:- 这是Windows Phone上的- TableView tableView1 = new TableView() { Intent = TableIntent.Form, Vertic

我在
Xamarin.Forms 1.4.2
中有一个
StackLayout
,我正试图从后面的代码创建一个表视图,然后为了测试,我在
StackLayout
中有一个按钮来重新创建
表视图

如果我使用标准的
TextCell
,那么我可以根据自己的意愿多次重新创建
TableView
,而不会导致应用程序崩溃:-

这是Windows Phone上的
-

TableView tableView1 = new TableView()
{
    Intent = TableIntent.Form,
    VerticalOptions = LayoutOptions.FillAndExpand
};
myStackLayoutControl.Children.Add(tableView1);

tableView1 = new TableRoot()
{
    new TableSection("Section 1")
    {
        new TextCell()
        {
            Text = "Text1",
            Detail = "Text2"
        }
    }
};
但是,当我将
TextCell
更改为
ViewCell
时,例如:-

new ViewCell()
{
    View = new Label()
    {
        Text="hello",
        HorizontalOptions = LayoutOptions.FillAndExpand,
        VerticalOptions = LayoutOptions.FillAndExpand
    },
    Height = 100
}
它将在第一次执行时正确显示
表视图

但是,单击一个按钮,清除
表视图
并执行相同的代码以重新创建它,将运行相同的代码,但是在它完成功能后,它将使整个应用程序崩溃,并捕获应用程序未处理的异常

捕获的异常是:-

MeasureOverride元素“Xamarin.Forms.Platform.WinPhone.ViewToRenderConverter+WrapperControl”不应将PositiveInfinity或Nan作为其所需大小返回。


有人知道如何解决这个问题吗?

当你搜索例外时,会有两个结果与你的问题相似。这似乎与
horizontalpoptions=LayoutOptions.FillAndExpand
有关。您可以尝试将其设置为除
FillAndExpand
Fill
之外的其他内容吗?是的,这似乎对特定问题进行了排序。当您搜索异常时,有两个结果与您的问题类似。这似乎与
horizontalpoptions=LayoutOptions.FillAndExpand
有关。您可以尝试将其设置为除
FillAndExpand
Fill
之外的其他内容吗?是的,这似乎对特定问题进行了排序。当您搜索异常时,有两个结果与您的问题类似。这似乎与
horizontalpoptions=LayoutOptions.FillAndExpand
有关。您可以尝试将其设置为除
FillAndExpand
Fill
之外的其他值吗?是的,这似乎对特定问题进行了排序。