Problem with redrawing listview row height in iOS

I have a ListView of items that are made up of a button, a label, and then a picker and an entry. By default, the entry is hidden. If the picker item selected is one that requires a note field to be completed, the entry will become visible. This works great on Android. I have attached screenshots of what I get on iOS.

The first image is the default appearance. Which is as intended. When the picker is changed to another item to trigger the entry visibility to true, it appears but it doesn't resize the row height. (as shown in 2nd image) If I change the orientation of the device, it will refresh the row height and show as intended (3rd image).

I'm actually having multiple issues with items not refreshing properly in iOS and wondering if anyone has ran into something similar that could provide some assistance.__

Answers

  • David.WelshDavid.Welsh USMember

    The above post was me. Not sure how it got posted with that other account. I'm still signed in on this one too. Weird.

  • FredyWengerFredyWenger CHInsider ✭✭✭✭✭

    @David.Welsh:

    You don't want rename to Xamarin.Skillweb (as Skillweb sounds good)...? :wink:
    Joking aside, you should send this problem to Xamarin-Support.
    To your problem, you should post some code (is the ListView bound..?, do you have a datatemplate (ViewCell) set..?)

  • David.WelshDavid.Welsh USMember

    I've just noticed that the images I've uploaded to the original post don't seem to be there. Strange behaviour on the forums today! I've added them again in this post. (see below)

    @FredyWenger To answer your questions, yes. Here's my listview. Hope you like Xaml. :smile:

    <ListView Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" ItemsSource="{Binding Products}" HasUnevenRows="True"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <Grid BackgroundColor="{Binding BackgroundColour, Converter={StaticResource StringToColorConverter}}"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <Button Grid.Row="0" Grid.Column="0" Grid.RowSpan="5" VerticalOptions="FillAndExpand" HorizontalOptions="CenterAndExpand" Style="{StaticResource ButtonStyle}" Image="{Binding ConsignmentTypeImage}" BackgroundColor="{Binding ConsignmentTypeColor, Converter={StaticResource StringToColorConverter}}" Command="{Binding PerformToggleConsignmentType}" BorderRadius="0"/> <Label Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" Text="{Binding Barcode}" Font="{x:Static local:Fonts.LargeFont}" VerticalOptions="CenterAndExpand" HorizontalOptions="StartAndExpand"/> <Frame Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Padding="3" BackgroundColor="#FFFFFFFF" OutlineColor="Gray" HasShadow="False" IsVisible="{Binding Grouped, Converter={StaticResource BooleanToInvertedBooleanConverter}}"> <Grid Padding="6,0,0,0"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Image Grid.Column="0" Source="{Binding ProductSuccessFailureImage}" Opacity="0.75" HorizontalOptions="Center" VerticalOptions="Center"/> <stvc:BindablePicker Grid.Column="1" ItemsSource="{Binding TrackAndTraceTypes}" SelectedIndex="{Binding SelectedTrackAndTraceIndex}" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" IsVisible="{Binding Grouped, Converter={StaticResource BooleanToInvertedBooleanConverter}}"/> </Grid> </Frame> <Label Text="" Grid.Row="2" IsVisible="{Binding Grouped}"/> <scvc:ClearableEntry Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3" EntryText="{Binding TandTNote}" EntryPlaceholder="{Binding TandTNotePlaceholder}" EntryIcon="{Binding NoteEntryIcon}" IsVisible="{Binding ShowTandTNote}" HorizontalOptions="Fill"/> </Grid> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView>

  • FredyWengerFredyWenger CHInsider ✭✭✭✭✭

    @David.Welsh:


    Hope you like Xaml

    Unfortunately no (I don't use XAML and do all in code...) :cry:
    In code, I would do the ViewCell with a StackLayout (instead of a Grid).
    But... I'm sure that some "XAML-lovers" can give you an answer.. :wink:

    And, you really should send a mail to the Xamarin-support regarding your forum-problem...

  • David.WelshDavid.Welsh USMember

    So it looks like this is caused by the HasUnevenRows property not working in iOS. Is there a good work around to this?

  • FredyWengerFredyWenger CHInsider ✭✭✭✭✭

    @David.Welsh:
    Since a few versions, HasUnevenRows works in iOS with ListView.
    I use ListView's with custom ViewCell (Datatemplate) on various pages (with variable height) (in code not XAML).
    Maybe you want to check this out...

  • David.WelshDavid.Welsh USMember

    @FredyWenger Ah thanks. I'm reading some old posts maybe. I'll have a look.

  • David.WelshDavid.Welsh USMember

    Hmm it seems my uneven rows are working. I've got 2 things in the list and they're different sizes. So this isn't the issue. I've tried reworking the layout to use a stacklayout too. No difference though. Must be an issue refreshing the view.

  • David.WelshDavid.Welsh USMember

    This is still an issue for me unfortunately. Anyone ever worked this out?

  • I am now fighting with the listview truncation problem in every project. This is a big pain.

  • MaxMengMaxMeng NZMember ✭✭✭

    I am not an iOS expert, if I'm wrong, please correct me.

    In iOS, view cell seems not auto re-calc height after changes. You need to manually call Control.ReloadRows in ListViewRenderer. To get the 1st param of this method, you may call this Foundation.NSIndexPath.FromIndex

Sign In or Register to comment.