Xamarin.forms 如何将值绑定到xamarin中listview内的选择器

Xamarin.forms 如何将值绑定到xamarin中listview内的选择器,xamarin.forms,Xamarin.forms,在xamarin表单中,我使用的是列表视图,我需要在其中实现picker。因为我们不能从列表视图中取出id,所以我不能将值加载到picker。有没有任何可能的方法可以做到这一点。下面是包含listview的xaml代码 <ListView x:Name="list_propertyCell" RowHeight="350" SeparatorVisibility="None"> <ListView.ItemTemplate> <Dat

在xamarin表单中,我使用的是列表视图,我需要在其中实现picker。因为我们不能从列表视图中取出id,所以我不能将值加载到picker。有没有任何可能的方法可以做到这一点。下面是包含listview的xaml代码

      <ListView x:Name="list_propertyCell" RowHeight="350" SeparatorVisibility="None">
    <ListView.ItemTemplate>
      <DataTemplate>
        <ViewCell>
          <StackLayout Orientation="Vertical">

            <Grid HorizontalOptions="FillAndExpand"
   Margin="10" >
              <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
              </Grid.RowDefinitions>

              <Grid.ColumnDefinitions>

                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
              </Grid.ColumnDefinitions>

              <Label Text="Claim Period-Month" TextColor="Gray"  FontSize="14" FontFamily="avenir" Grid.Row="0" Grid.Column="0" >
                <Label.FontFamily>
                  <OnPlatform x:TypeArguments="x:String"
                           iOS="avenir"
                                   Android="Fonts/AvenirLTStd-Book.ttf#AvenirLTStd-Book"/>
                </Label.FontFamily>
              </Label>
              <Entry Text="{Binding PropertyDate}" Placeholder="{Binding ddlvalue}" FontSize="14" Grid.Row="1" Grid.Column="0" IsEnabled="{Binding enabled}" PlaceholderColor="Black">
                <Entry.FontFamily>
                  <OnPlatform x:TypeArguments="x:String"
                         iOS="avenir"
                                   Android="Fonts/AvenirLTStd-Book.ttf#AvenirLTStd-Book"/>
                </Entry.FontFamily>
              </Entry>
                                <Button Grid.Row="1" Grid.Column="0" Clicked="populate" BackgroundColor="Transparent" IsEnabled="{Binding enabled}"/>
              <Label Text="Claim Period-Year" TextColor="Gray"  FontSize="14" FontFamily="avenir" Grid.Row="0" Grid.Column="1" >
                <Label.FontFamily>
                  <OnPlatform x:TypeArguments="x:String"
                           iOS="avenir"
                                   Android="Fonts/AvenirLTStd-Book.ttf#AvenirLTStd-Book"/>
                </Label.FontFamily>
              </Label>
                <Entry Text="{Binding PropertyDate1}" Completed="periodyear" ClassId="{Binding claimdetailId}" FontSize="14" Grid.Row="1" Grid.Column="1" IsEnabled="{Binding enabled}" PlaceholderColor="Black">
                <Entry.FontFamily>
                  <OnPlatform x:TypeArguments="x:String"
                         iOS="avenir"
                                   Android="Fonts/AvenirLTStd-Book.ttf#AvenirLTStd-Book"/>
                </Entry.FontFamily>
              </Entry>

                                <Button Grid.Row="1" Grid.Column="1" Clicked="populateclaim1" BackgroundColor="Transparent" IsEnabled="{Binding enabled}"/>
                                <Label Text="Payment Type" TextColor="Gray" FontSize="14" FontFamily="avenir" Grid.Row="2" Grid.Column="0">
                <Label.FontFamily>
                  <OnPlatform x:TypeArguments="x:String"
                           iOS="avenir"
                                   Android="Fonts/AvenirLTStd-Book.ttf#AvenirLTStd-Book"/>
                </Label.FontFamily>
              </Label>

                                <local:BindablePicker  ItemsSource="{Binding Cats}" SelectedItem="{Binding SelectedCat}" Grid.Row="2" Grid.Column="0"></local:BindablePicker>
                                <Entry Text="{Binding paymenttype}" Placeholder="{Binding ddlvalue1}" FontSize="14" Grid.Row="3" Grid.Column="0" IsEnabled="{Binding enabled}" PlaceholderColor="Black">
                <Entry.FontFamily>
                  <OnPlatform x:TypeArguments="x:String"
                         iOS="avenir"
                                   Android="Fonts/AvenirLTStd-Book.ttf#AvenirLTStd-Book"/>
                </Entry.FontFamily>
              </Entry>
                                <Button Grid.Row="3" Grid.Column="0" Clicked="populateclaim" BackgroundColor="Transparent" IsEnabled="{Binding enabled}"/>


              <Label Text="Driver Name" TextColor="Gray"  FontSize="14" FontFamily="avenir" Grid.Row="2" Grid.Column="1">
                <Label.FontFamily>
                  <OnPlatform x:TypeArguments="x:String"
                           iOS="avenir"
                                   Android="Fonts/AvenirLTStd-Book.ttf#AvenirLTStd-Book"/>
                </Label.FontFamily>
              </Label>
              <Entry Completed="drivername" IsEnabled="{Binding enabled}" Text="{Binding drivername}" PlaceholderColor="Gray" FontSize="14" FontFamily="avenir" Grid.Row="3" Grid.Column="1">
                <Entry.FontFamily>
                  <OnPlatform x:TypeArguments="x:String"
                           iOS="avenir"
                                   Android="Fonts/AvenirLTStd-Book.ttf#AvenirLTStd-Book"/>
                </Entry.FontFamily>
              </Entry>

                                <Label Text="Scanned Document" TextColor="Gray" IsVisible="False" FontSize="14" FontFamily="avenir" Grid.Row="4" Grid.Column="0">
                <Label.FontFamily>
                  <OnPlatform x:TypeArguments="x:String"
                           iOS="avenir"
                                   Android="Fonts/AvenirLTStd-Book.ttf#AvenirLTStd-Book"/>
                </Label.FontFamily>
              </Label>
                                <local:ButtonUploadClick Text="Choose" IsVisible="False" FontSize="14" FontFamily="avenir" Grid.Row="5" Grid.Column="0" BackgroundColor="Transparent"/>



              <Label Text="Claim Amount" TextColor="Gray"  FontSize="14" FontFamily="avenir" Grid.Row="4" Grid.Column="1">
                <Label.FontFamily>
                  <OnPlatform x:TypeArguments="x:String"
                           iOS="avenir"
                                   Android="Fonts/AvenirLTStd-Book.ttf#AvenirLTStd-Book"/>
                </Label.FontFamily>
              </Label>
              <Entry Completed="claimamount" IsEnabled="{Binding enabled}" Text="{Binding amount}" Grid.Row="5" Grid.Column="1" PlaceholderColor="Gray" FontSize="14" FontFamily="avenir">
                <Entry.FontFamily>
                  <OnPlatform x:TypeArguments="x:String"
                           iOS="avenir"
                                   Android="Fonts/AvenirLTStd-Book.ttf#AvenirLTStd-Book"/>
                </Entry.FontFamily>
              </Entry>
                                <Button x:Name="delete" Text="Delete" ClassId="{Binding btn_tag}" BackgroundColor="Transparent"  Grid.Row="6"
     Grid.Column="0" Clicked="DeleteSeletecItem" IsVisible="True" HorizontalOptions="CenterAndExpand"></Button>







                            </Grid>

          </StackLayout>


        </ViewCell>
      </DataTemplate>
    </ListView.ItemTemplate>

  </ListView>


我找不到你。您的意思是,您在单击时会得到选择器弹出窗口,而值不会显示在弹出窗口中?如果是这样的话,试着将猫声明为可观察的集合

我找不到你。您的意思是,您在单击时会得到选择器弹出窗口,而值不会显示在弹出窗口中?如果是这种情况,请尝试将Cats声明为可观察集合

自2.3.4起,
Xamarin.Forms
选择器
是可绑定的。您可以在数据模板中绑定ItemsSource,就像在其中绑定其他所有值一样。

自2.3.4以来,
Xamarin。表单
选择器
是可绑定的。您可以在数据模板中绑定ItemsSource,就像在其中绑定其他所有值一样。

所以您应该有一个列表视图,其中每行都有一个选择器?我找不到您。列表视图包含多个嵌入网格中的条目和标签,我也需要选择器。您可以发布您的模型吗,谢谢。谢谢……所以你应该有一个列表视图,其中每一行都有它的选择器?我找不到你。列表视图包含多个条目和标签嵌入在网格中,我也需要选择器。你能发布你的模型吗,谢谢。谢谢。。。。