Xamarin表单-删除多余的空间/嵌入ListView [英] Xamarin Forms - remove extra space / embedded ListView

查看:133
本文介绍了Xamarin表单-删除多余的空间/嵌入ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找出如何删除下图中显示的空白(由红色矩形包围).注意,我在父ListView中嵌入了一个ListView.

I am trying to figure out how to remove the white space you see in the image below (surrounded by a red rectangle). Notice I have a ListView embedded in a parent ListView.

XAML

<ListView x:Name="___listview" HasUnevenRows="True">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <StackLayout>
                    <Button Image="{Binding ImageName}" Command="{Binding ShowDetailsCommand}" />
                    <ListView ItemsSource="{Binding Notes}">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <TextCell Text="{Binding Note}" />
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                </StackLayout>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

这可能不是必需的,但这是模型...

This probably isn't needed, but here is the model...

模型

namespace ViewCellClick
{
    public class ModelBase : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    public class Model : ModelBase
    {
        public Model()
        {
            _imageName = "ellipses_vertical.png";
            _showDetails = true;
            ShowDetailsCommand = new Command(() =>
            {
                ShowDetails = !_showDetails;
                ImageName = (_imageName == "ellipses_vertical.png")
                                        ? "ellipses_horizontal.png"
                                        : "ellipses_vertical.png";
            });
        }

        bool _showDetails;
        public bool ShowDetails
        {
            get { return _showDetails; }
            set { if (_showDetails != value) { _showDetails = value; OnPropertyChanged("ShowDetails"); } }
        }

        string _imageName;
        public string ImageName
        {
            get { return _imageName; }
            set { if (_imageName != value) { _imageName = value; OnPropertyChanged("ImageName"); } }
        }

        public ICommand ShowDetailsCommand { get; set; }

        List<ChildModel> _notes;
        public List<ChildModel> Notes { get { return _notes; } set { _notes = value; } }
    }

    public class ChildModel : ModelBase
    {
        public ChildModel(string note) { _note = note; }
        string _note;
        public string Note
        {
            get { return _note; }
            set { if (_note != value) { _note = value; OnPropertyChanged("Note"); } }
        }
    }
}

推荐答案

您不能使用Xamarin.Forms.ListView进行此操作,并且不支持嵌套它们.真的,在iOS上这将非常困难,而且我不确定如果没有一些奇怪的手势行为,您是否可以使其正常工作.

You can't do this with Xamarin.Forms.ListView and nesting them is not supported. Really on iOS this would be very difficult and I'm not sure you could get it working without some weird gesture behavior.

这篇关于Xamarin表单-删除多余的空间/嵌入ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆