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

"An item with the same key has already been added" exception when adding nested ScrollView to Xaml

$
0
0

I have the following markup in my Xaml:

<ScrollView Orientation="Vertical">
    <StackLayout VerticalOptions="StartAndExpand" HorizontalOptions="CenterAndExpand">
      <Label>Johnny's Diary</Label>
    </StackLayout>
    <ListView ItemsSource="{Binding GroupedItems}" IsGroupingEnabled="True" GroupDisplayBinding="{ Binding Day }" IsEnabled="False" InputTransparent="True">
      <ListView.ItemTemplate>
        <DataTemplate>
          <TextCell  Text="{Binding Title}" Detail="{Binding Text}"></TextCell>

        </DataTemplate>
      </ListView.ItemTemplate>
    </ListView>
  </ScrollView>

However, when I add in an inner ScrollView:

<ScrollView Orientation="Vertical">
      <StackLayout VerticalOptions="StartAndExpand" HorizontalOptions="CenterAndExpand">
        <Label>Johnny's Diary</Label>
      </StackLayout>
      <ListView ItemsSource="{Binding GroupedItems}" IsGroupingEnabled="True" GroupDisplayBinding="{ Binding Day }" IsEnabled="False" InputTransparent="True">
        <ListView.ItemTemplate>
          <DataTemplate>
            <TextCell  Text="{Binding Title}" Detail="{Binding Text}"></TextCell>
            <ScrollView Orientation="Horizontal">

            </ScrollView>
          </DataTemplate>
        </ListView.ItemTemplate>
      </ListView>
    </ScrollView>

I get the following exception:

An item with the same key has already been added

It seems to be happening when InitializeComponent is called in the Xaml code behind.

Is this a drawback of Xamarin Forms? Can't I nest controls of the same type, this seems a little silly? How can I get around this issue?

Thanks

Mark


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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