Value cannot be null.Parameter name: fieldType

480 Views Asked by At

I have a x:Array of View type, and I'm trying to put inside a ListView, like this: Code Then this error appears: Error But if I remove the ItemTemplate, the project runs: Running Please, I need your help, I can't find what is wrong

1

There are 1 best solutions below

0
On

This answer is not maybe too late to be helpful for you, but it is the first result that appears once you google the problem. I had the same problem and solved it as follows:

  1. I had a contentPage that contained a slider, in the slider I had an array of ContentViews

    <telerikPrimitives:RadSlideView Grid.Row="0" Grid.Column="1" 
                                    Grid.RowSpan="2" ShowIndicators="False" 
                                    IsSwipingEnabled="False" ShowButtons="False">
        <telerikPrimitives:RadSlideView.ItemsSource>
            <x:Array Type="{x:Type ContentView}">
                <ContentView>
                    <StackLayout Padding="10,10,10,10">
                        <Label Text="Customer:" TextColor="Black" HorizontalOptions="Start" FontAttributes="Bold" />
                        <telerikInput:RadComboBox
                            ItemsSource="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:EmptyViewModel}}, Path=Customers}"
                            DisplayMemberPath="Name" IsEditable="True" OpenOnFocus="False"
                            SearchMode="Contains" SearchTextPath="Name" 
                            DropDownHeight="80"
                            Placeholder="Select a customer"
                            >
                            <telerikInput:RadComboBox.ItemTemplate>
                                <DataTemplate>
                                                <telerikPrimitives:RadBorder BorderColor="#cc0000" BorderThickness="0,0,0,1">
        <StackLayout Padding="15,10,0,10">
            <telerikPrimitives:RadHighlightLabel Text="{Binding Name}" TextColor="Black"/>
        </StackLayout>
    </telerikPrimitives:RadBorder>
                                </DataTemplate>
                            </telerikInput:RadComboBox.ItemTemplate>
                        </telerikInput:RadComboBox>
                        <Button Text="next" Command="{Binding NextItemCommand, Source={RelativeSource AncestorType={x:Type telerikPrimitives:RadSlideView}}}" 
                                />
                    </StackLayout>
                </ContentView>
            </x:Array>
        </telerikPrimitives:RadSlideView.ItemsSource>
    </telerikPrimitives:RadSlideView>
    
  2. The problem appeared once something once I added something to DataTemplate. What I noticed is if I removed the code and started my app and added the code while the app is running it worked fine.

  3. The solution to my problem was: Create a separate ContentView file and just reference it from the the ContentPage. It looks like this:

    <telerikPrimitives:RadSlideView Grid.Row="0" Grid.Column="1" 
                                    Grid.RowSpan="2" ShowIndicators="False" 
                                    IsSwipingEnabled="False" ShowButtons="False">
        <telerikPrimitives:RadSlideView.ItemsSource>
            <x:Array Type="{x:Type ContentView}">
                <views:EmptyViewPart1/>
            </x:Array>
        </telerikPrimitives:RadSlideView.ItemsSource>
    </telerikPrimitives:RadSlideView>
    

The contentView contained the code.

The solution for your problem could be the same, where you put your views in separate files and use Relative binding to the access the data.