Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Multiple ListView in same Xaml throws NSRangeException in iOS

$
0
0

I have 3 listview in xaml, each one binded to its own list on the viewmodel, for some reason that i dont understand, if one of the list has 4 elements and the others have 3, i am unable to acess 4 element in the first one and it throws the following exception in ios : SRangeException Reason: -[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:usingPresentationValues:]: row (4) beyond bounds (4) for section (0).

Does anyone know why its forcing me to have the same number of elements in each listview? It doesnt make any sense.
They are separated listviews, they are binded to separated lists i dont understand

This is the xaml:


<ListView.ItemTemplate>




        <SearchBar x:Name="leadsSearch"  IsVisible="False" Placeholder="Busca" TextChanged="SearchBar_TextChangedLeads" HeightRequest="50"/>
        <ListView x:Name="leadsList" Margin="5" IsVisible="False" ItemsSource="{Binding Leads}" SelectedItem="{Binding LeadSeleccionado, Mode=TwoWay}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout Orientation="Horizontal">
                            <Label Text="{Binding recordLabel}" VerticalTextAlignment="Center" LineBreakMode="TailTruncation"
                                   HorizontalOptions="FillAndExpand" TextColor="Black" FontSize="18"/>
                            <Image Source="llamada.png" VerticalOptions="Center" HorizontalOptions="End" HeightRequest="100" WidthRequest="50" >
                                <Image.GestureRecognizers>
                                    <TapGestureRecognizer
                                       Command="{Binding Path=BindingContext.LlamarLeadAction, Source={x:Reference Name= leadsList}}"
                                        CommandParameter="{Binding}"
                                        NumberOfTapsRequired="1" />
                                </Image.GestureRecognizers>
                            </Image>
                            <Image Source="correo.png" VerticalOptions="Center" HorizontalOptions="End" HeightRequest="100" WidthRequest="50">
                                <Image.GestureRecognizers>
                                    <TapGestureRecognizer
                                       Command="{Binding Path=BindingContext.CorreoLeadAction, Source={x:Reference Name= leadsList}}"
                                        CommandParameter="{Binding}"
                                        NumberOfTapsRequired="1" />
                                </Image.GestureRecognizers>
                            </Image>
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

        <SearchBar x:Name="emprSearch" IsVisible="False" Placeholder="Busca" TextChanged="SearchBar_TextChangedEmpresas" HeightRequest="50"/>
        <ListView x:Name="empresasList" Margin="5" IsVisible="False" ItemsSource="{Binding Empresas}" 
                  ItemSelected="empresasList_ItemSelected" HasUnevenRows="True" CachingStrategy="RecycleElement">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout Orientation="Horizontal">
                            <Image Source="empresa.png" Margin="10,0,10,0"/>
                            <Label Text="{Binding recordLabel}" VerticalTextAlignment="Center" LineBreakMode="TailTruncation"
                                   HorizontalOptions="FillAndExpand" TextColor="Black" FontSize="18"/>
                            <Image Source="llamada.png" VerticalOptions="Center" HorizontalOptions="End" HeightRequest="100" WidthRequest="50" >
                                <Image.GestureRecognizers>
                                    <TapGestureRecognizer
                                       Command="{Binding Path=BindingContext.LlamarEmpresaAction, Source={x:Reference Name= empresasList}}"
                                        CommandParameter="{Binding}"
                                        NumberOfTapsRequired="1" />
                                </Image.GestureRecognizers>
                            </Image>
                            <Image Source="correo.png" VerticalOptions="Center" HorizontalOptions="End" HeightRequest="100" WidthRequest="50">
                                <Image.GestureRecognizers>
                                    <TapGestureRecognizer
                                       Command="{Binding Path=BindingContext.WebEmpresaAction, Source={x:Reference Name= empresasList}}"
                                        CommandParameter="{Binding}"
                                        NumberOfTapsRequired="1" />
                                </Image.GestureRecognizers>
                            </Image>
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>