【发布时间】:2017-05-11 18:26:42
【问题描述】:
在 xamarin 表单中,我正在使用列表视图,我需要在其中实现选择器。由于我们无法从列表视图中取出 id,我无法将值加载到选择器。有没有办法做到这一点。这是包含列表视图的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>
【问题讨论】:
-
所以你应该有一个 Listview 每一行都有它的选择器?
-
我找不到你。Listview 包含嵌入在网格中的多个条目和标签,我也需要选择器。
-
可以发一下你的模特吗,谢谢
-
好的。谢谢....
标签: xamarin.forms