Dynamically Populate Picker that is part of a ListView's ItemTemplate

PaulDistonPaulDiston USUniversity ✭✭✭✭

Hi,

I have a ListView, with an ItemTemplate as follows :-

    <ListView Grid.Row="2"
              Grid.ColumnSpan="3"
              HorizontalOptions="Center"
              ItemsSource="{Binding Products, Mode=TwoWay}"
              x:Name="MyListView">
      <ListView.ItemTemplate>
        <DataTemplate>
          <ViewCell>
            <Grid>
              <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
              </Grid.RowDefinitions>
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
              </Grid.ColumnDefinitions>
              <Label Grid.Row="0"
                     Grid.Column="0"
                     Text="{Binding Barcode}"
                     Font="20"
                     HorizontalOptions="Center"/>
              <Picker Grid.Row="0"
                      Grid.Column="1"
                      x:Name="MyPicker"/>
            </Grid>
          </ViewCell>
        </DataTemplate>
      </ListView.ItemTemplate>
    </ListView>

As I add items to the Products collection, I would like the Picker control to be populated with some additional data.

I understand that you can not Bind the Items property of the Picker control, therefore I would need to add the Items in the code behind, however I am unsure how I might access the Picker control for each of the rows in the ListView.

I have tried hooking into the ItemAppearing event handler of the ListView however that only gives me the underlying data and not access to the controls that make up the ItemTemplate.

Thanks

Paul Diston

Posts

  • EricMaupinEricMaupin USXamarin Team Xamurai

    There's currently no way of accessing items created by the template in a ListView. You'll have to use TableView and create the cells manually for now.

  • PaulDistonPaulDiston USUniversity ✭✭✭✭

    Thank you very much for your reply.

    Is there a plan in the future to support this?

Sign In or Register to comment.