C1 for Xamarin FlexGridDetailProvider Height="Auto" is being ignored

Posted by: erick.duarte.godoy on 11 October 2017, 9:01 am EST

    • Post Options:
    • Link

    Posted 11 October 2017, 9:01 am EST

    Hi,

    It happens that I want the Height property of FlexGridDetailProvider to match the number of elements inside,

    This works perfectly in iOS, with the value “Auto” in the Height property, it is in Android where it does not work in the same way.

    Any ideas? Your comments will help me a lot.

    Thanks in advance for the help.

    Greetings

    Erick,

  • Posted 12 October 2017, 7:17 am EST

    Hi Erick

    I don’t see issues with build 189. For instance I modified the RowDetails sample in FlexGrid101 so that the FlexGridDetailProvider looks as follows:

    <c1:FlexGridDetailProvider x:Name="details" Height="Auto" RowHeaderLoading="OnRowHeaderLoading">
              <DataTemplate> 
                <Grid Margin="4">
                  <Grid.RowDefinitions>
                    <RowDefinition Height="170"/>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                  </Grid.RowDefinitions>
                  <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                  </Grid.ColumnDefinitions>
                  <Label Text="Country:"/>
                  <Label Text="{Binding Country}" Grid.Column="1"/>
                  <Label Text="City:" Grid.Row="1"/>
                  <Label Text="{Binding City}" Grid.Row="1" Grid.Column="1"/>
                  <Label Text="Address:" Grid.Row="2"/>
                  <Label Text="{Binding Address}" Grid.Row="2" Grid.Column="1"/>
                  <Label Text="PostalCode:" Grid.Row="3"/>
                  <Label Text="{Binding PostalCode}" Grid.Row="3" Grid.Column="1"/>
                </Grid>
              </DataTemplate>
            </c1:FlexGridDetailProvider>
    

    This worked as I expected. I’d recommend upgrading if you’re on an earlier version, and sharing some more info about your code and Android version you’re targeting.

    Thanks

    Kelley

  • Posted 17 October 2017, 4:13 am EST

    For example, I have these two classes…

    Model: Person.cs , Hobby.cs

    public class Persona : BindableBase
        {
            private string _Name;
            public string Name
            {
                get { return _Name; }
                set { SetProperty(ref _Name, value); }
            }
            private string _LastName;
            public string LastName
            {
                get { return _LastName; }
                set { SetProperty(ref _LastName, value); }
            }
            private ObservableCollection<Hobby> _ListHobbies;
            public ObservableCollection<Hobby> ListHobbies
            {
                get { return _ListHobbies; }
                set { SetProperty(ref _ListHobbies, value); }
            }
        }
    
      public class Hobby : BindableBase
        {
            private string _Description;
            public string Description
            {
                get { return _Description; }
                set { SetProperty(ref _Description, value); }
            }
        }
    

    ViewModel: PersonViewModel.cs

      public class PersonViewModel : BindableBase
        {
            private ObservableCollection<Persona> _Person;
            public ObservableCollection<Persona> Person
            {
                get { return _Person; }
                set { SetProperty(ref _Person, value); }
            }
            
            public PersonViewModel()
            {
                this.Person = new ObservableCollection<Persona>()
                {
                    new Persona()
                    {
                        Name ="Erick",
                        LastName ="Duarte",
                        ListHobbies= new ObservableCollection<Hobby>()
                        {
                            new Hobby{Description="Guitar"}
                        }
                    },
                    new Persona()
                    {
                        Name ="Andres",
                        LastName ="Lopez",
                        ListHobbies= new ObservableCollection<Hobby>()
                        {
                              new Hobby{Description="Guitar"},
                              new Hobby{Description="Play XBox"}
                        }
                    },
                     new Persona()
                    {
                        Name ="Ana",
                        LastName ="Perez",
                        ListHobbies= new ObservableCollection<Hobby>()
                        {
                            new Hobby{Description="Piano"},
                            new Hobby{Description="Gym"},
                            new Hobby{Description="Shopping"},
                            new Hobby{Description="Online games"}
                        }
                    }
                };
            }
        }
    

    XAML: Person.xaml

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage
        x:Class="AuthExpress.Views.Person"
        xmlns="http://xamarin.com/schemas/2014/forms"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        xmlns:c1="clr-namespace:C1.Xamarin.Forms.Grid;assembly=C1.Xamarin.Forms.Grid"
        xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
        prism:ViewModelLocator.AutowireViewModel="True">
    
    
        <ContentPage.Content>
            <c1:FlexGrid ItemsSource="{Binding Person}"
    				AutoGenerateColumns="False">
                <c1:FlexGrid.Columns>
                    <c1:GridColumn Binding="Name" Header="Name" />
                    <c1:GridColumn Binding="LastName" Header="LastName" />
                </c1:FlexGrid.Columns>
                <c1:FlexGrid.Behaviors>
                    <c1:FlexGridDetailProvider Height="Auto" DetailVisibilityMode="ExpandMultiple">
                        <DataTemplate>
                            <c1:FlexGrid ItemsSource="{Binding ListHobbies}" 					
     						AutoGenerateColumns="False">
                                <c1:FlexGrid.Columns>
                                    <c1:GridColumn Binding="Description" Header="Hobby" />
                                </c1:FlexGrid.Columns>
                            </c1:FlexGrid>
                        </DataTemplate>
                    </c1:FlexGridDetailProvider>
                </c1:FlexGrid.Behaviors>
            </c1:FlexGrid>
        </ContentPage.Content>
    </ContentPage>
    

    iOS:

    https://www.dropbox.com/s/m4v4o5hzdt12pdw/Simulator%20Screen%20Shot%20-%20iPhone%208%20-%202017-10-17%20at%2010.52.47.png?dl=0

    Android (I would like it to look just like on iOS):

    https://www.dropbox.com/s/38alcfhixahbc9r/AndroidCapture.png?dl=0

    By the way, the Android version I use is 6.0 onwards and componentone is the most recent 189

    Thanks a lot for your help Kelley!

  • Posted 17 October 2017, 7:22 am EST

    Hi Erick

    OK, I can reproduce that here. Let me talk with the developers and have them take a look at it.

    Thanks

    Kelley

  • Posted 26 January 2018, 2:15 am EST

    Hi Erick

    This issue should be fixed in build 2.5.20173.241 which is now live on nuget.org.

    Thanks

    Kelley

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels