0

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.

enter image description here

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...

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"); } }
        }
    }
}
John Livermore
  • 30,235
  • 44
  • 126
  • 216
  • 1
    ListView in ListView ist not supported in Xamarin Forms and was already discussed [here](http://stackoverflow.com/questions/35223540/listview-inside-listview-xamarin-forms) – Marius Junak Jan 13 '17 at 22:22

1 Answers1

1

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.

BrewMate
  • 1,010
  • 5
  • 15
  • I was able to implement this a different way. Basically the technique is to extend ViewCell. In the constructor I create a StackLayout and set it to the View. In OnAppearing, I create the controls with C#, and I can cycle through the inner list to build the same thing I was trying to accomplish with the embedded ListView. – John Livermore Jan 16 '17 at 22:57
  • can you tell me how yu do it? –  Apr 20 '17 at 08:39