如何在Xamarin窗体上使用自动设置行高?

如何在Xamarin窗体上使用自动设置行高?,xamarin,xamarin.ios,xamarin.forms,Xamarin,Xamarin.ios,Xamarin.forms,我正在尝试创建一个在ItemTemplate上有DataTemplateSelector的ListView。基本上,它看起来像一个可扩展的单元格,当选择项目时,它会显示更多信息 DataTemplateSelector上的我的代码: protected override DataTemplate OnSelectTemplate(object item, BindableObject container) { return ((ItemAjuda)item).Se

我正在尝试创建一个在ItemTemplate上有DataTemplateSelector的ListView。基本上,它看起来像一个可扩展的单元格,当选择项目时,它会显示更多信息

DataTemplateSelector上的我的代码:

protected override DataTemplate OnSelectTemplate(object item, BindableObject     container)
    {
        return ((ItemAjuda)item).Selecionado ? ExpandedTemplate : SimpleTemplate;
    }
这是我在视图中的代码:

<ListView
                    x:Name = "listView"
                    SeparatorVisibility = "None"
                    RowHeight = "-1"
                    HasUnevenRows="true" 
                    ItemsSource="{Binding Itens}" 
                    SelectedItem="{Binding ItemSelecionado, Mode=TwoWay}"
                    BackgroundColor = "{StaticResource DefaultBackground}">
                <ListView.ItemTemplate>
                    <local:AjudaTemplateSelector/>
                </ListView.ItemTemplate>
            </ListView>

它在安卓系统上运行得很好,但在IOS系统上,手机有一种奇怪的行为。行高度会发生变化,但看起来不像不均匀的行:(
Ps:我已经尝试在单元格上强制UpdateSize(),但不幸的是,它没有改变任何东西(可能是因为DataTemplateSelector?

Remove RowHeight=“-1”从listview和检查您的模板,可能是这里的错误。我尝试删除RowHeight=-1,但什么也没有发生。在我的模板中,我在两个StackLayout中都有VerticalOptions=FillAndExpand。检查此项,您应该对此进行深入研究。我有类似的情况,并使用了此方法。