Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

ListView not working in CarouselView

$
0
0

Greetings!

I am trying to include a ListView as an element in a static array in a CarouselView. This is the XAML code in my sandbox project:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:XamarinSandbox"
             xmlns:cv="clr-namespace:CarouselView.FormsPlugin.Abstractions;assembly=CarouselView.FormsPlugin.Abstractions"
             x:Class="XamarinSandbox.MainPage">

    <cv:CarouselViewControl x:Name="carousel" 
                            InterPageSpacing="10"
                            Orientation="Horizontal"
                            Position="{Binding Position}"
                            ShowArrows="True"
                            ShowIndicators="True"
                            HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">

        <cv:CarouselViewControl.ItemsSource>
            <x:Array Type="{x:Type View}">

                <Label Text="{Binding LabelText}" BackgroundColor="CadetBlue" FontSize="Large"
                       HorizontalTextAlignment="Center" HorizontalOptions="CenterAndExpand" VerticalTextAlignment="Center" VerticalOptions="CenterAndExpand" />

                <StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                    <Label Text="{Binding ProgramModeInstructionsText}" FontSize="Large"
                           HorizontalTextAlignment="Center" HorizontalOptions="CenterAndExpand" VerticalTextAlignment="Center" VerticalOptions="CenterAndExpand" />

                    <ListView ItemsSource="{Binding ItemsSource}" SelectedItem="{Binding SelectedItem}"
                              HasUnevenRows="True" HeightRequest="200" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                               <TextCell Text="REMOVE THIS LINE AND THE CODE COMPILES" />
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>

                    <Label Text="{Binding SelectedProgramModeDescription}" FontSize="Large"
                           HorizontalTextAlignment="Center" HorizontalOptions="CenterAndExpand" VerticalTextAlignment="Center" VerticalOptions="CenterAndExpand" />
                </StackLayout>

            </x:Array>
        </cv:CarouselViewControl.ItemsSource>

    </cv:CarouselViewControl>

</ContentPage>

With this XAML definition, I receive the following compilation error: Value cannot be null. Parameter name: fieldType
(I am using [assembly: XamlCompilation(XamlCompilationOptions.Compile)])

I have been removing lines and compiling to see where the error lays.
If I remove the TextCell element, then the XAML definition compiles without error.

I am at a loss to understand what is going on. This is a basic sandbox project with nothing else in it save the view model that responds to this view. However, I have removed every binding to make the example as simple as possible. The code behind class has had no code added to it.

Does anyone have any ideas why this is not compiling?
Using Xamarin version 2.5.0.280555.
Thank you.


Viewing all articles
Browse latest Browse all 204402

Trending Articles