0
votes

I have List View in Main-Page. I am using template selector to choose the templates which are resides in separate files(ViewCell). Now I need to use a list view in the selected template(separate file), but it gives run-time error and I am not able to get what is the error also. Below is the code snippet.

MainPage

 <ListView   Margin="0,0,0,0"  VerticalOptions="FillAndExpand"
                        SeparatorVisibility="None" HasUnevenRows="True"  
                        ItemTemplate="{StaticResource RequestTemplateSelector }" 
                        ItemsSource="{Binding LstInventoryRequests}" >
                    </ListView>

LstInventoryRequests(List of below class object)

Class 
{
    public string IssuedOn { get; set; }
    public string IssueId { get; set; }
    public ObservableCollection<InventoryDetailItemData>  ItemDetails { get; set; }
}

InventoryDetailItemData

 public string ItemName { get; set; }
    public int RequestedQty { get; set; }
    public int IssuedQty { get; set; }

Inside ViewCell(Separate file) being selected by templateselector

 <ListView 
         SeparatorVisibility="None" 
         ItemsSource="{Binding ItemDetails}">
                 <ListView.ItemTemplate>
                       <DataTemplate>
                           <ViewCell >
                             <ViewCell.View>
                                   <Label Text="{Binding ItemName}"/>
                              </ViewCell.View>
                            </ViewCell>
                         </DataTemplate>
                      </ListView.ItemTemplate>
     </ListView>

It gives me Run-time error and not able to find what is the issue in the above code. Can someone please help me finding it out?

1
And what is the error?Gerald Versluis
@GeraldVersluis I got the below information from output window 11-24 18:52:57.868 W/dalvikvm(19807): threadid=1: thread exiting with uncaught exception (group=0x41db3c08) An unhandled exception occured.Thavudu
I strongly recommend that you use ListView Grouping .ColeX - MSFT

1 Answers

0
votes

Try to remove these. <ViewCell.View> </ViewCell.View> from your code.

Let me know if it works.