2017-05-03 15 views
0

xamarinフォームでリストを使用しています。ピッカーを実装する必要があります。リストビューからIDを取り出すことができないため、ピッカーに値をロードできませんでした。これを行う可能な方法はありますか?xamlコードはリストビューを持っていますxamarinのリストビュー内のピッカーに値をバインドする方法

 <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> 
+0

だから、すべての行にピッカーが付いているリストビューが必要ですか? –

+0

私はあなたを得ることができませんでした.Listviewには複数のエントリとラベルがグリッドの中に埋め込まれていますが、ピッカーも必要です。 – Xamarin

+0

あなたのモデルを投稿できますか? –

答えて

0

私はあなたを取得できませんでした。クリックするとピッカーのポップが表示され、値がポップアップに表示されていないと言っていますか?この場合、ObservableCollectionとしてCatsを宣言してください。

1

2.3.4以降、Xamarin.FormsPickerはBindableです。 DataTemplate内のItemsSourceをバインドすることができます。そこに他のすべての値をバインドします。

関連する問題