我对xamarin形式的所选项目有疑问。 所选项目适用于除Android之外的所有项目。
那是当我单击无效的列表项时
我已经调试并注意到该函数没有被调用,但是仅在android中会发生这种情况,它是否有bug?还是我的错误?
感谢收听
PS。对不起,我的英语
SelectedItem方法
linha = (Linhas)e.SelectedItem;
foreach (Linhas item in objBList)
{
item.selected = (item == linha);
}
Device.BeginInvokeOnMainThread(() => {
lstView.ItemsSource = null;
lstView.ItemsSource = objBList;
});
ListView lista_linhas = (ListView)sender;
var linha_vat_converted = linha.Vat / 100;
p_name_e.Text = linha.Name_product;
p_code_e.Text = linha.Ref;
p_price_e.Text = linha.Pu.ToString("0.00#");
p_famaly_e.Text = linha.famaly_ref;
p_qtt_e.Text = linha.qtt.ToString("0.000#");
p_iva_e.Text = linha_vat_converted.ToString("P");
p_Unidade_e.Text = linha.Un;
此方法对我来说是获取所单击项目的数据,并将其传递给另一端的
Xml的ListView
<ListView x:Name="lstView" RowHeight="50" ItemSelected="Handle_ItemSelected_1" SeparatorVisibility="None" IsVisible="False" BackgroundColor="White" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Padding="5,10,5,5" >
<Grid.GestureRecognizers>
<TapGestureRecognizer
Tapped="testedalista"
NumberOfTapsRequired="2" />
</Grid.GestureRecognizers>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="10" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5" />
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<BoxView Grid.Column="0" Grid.RowSpan="2" IsVisible="{Binding selected}" BackgroundColor="#2379fb" Grid.Row="0"/>
<Label Grid.RowSpan="2" FontFamily="{StaticResource Open_Sans_Regular}" Margin="1,0,0,0" Grid.Column="1" Grid.Row="0" VerticalTextAlignment="Start" TextColor="#808080" Font="14" x:Name="linha_desc" Text ="{Binding Name_product}" Style ="{StaticResource SmallName}" />
<Label FontFamily="{StaticResource Open_Sans_Regular}" Margin="0,0,0,0" HorizontalTextAlignment="End" VerticalTextAlignment="Start" Grid.Row="0" TextColor="#808080" Font="14" Grid.Column="2" Text = "{Binding qtt , StringFormat= '{0:0.000#}'}" Style ="{StaticResource SmallName}" />
<Label FontFamily="{StaticResource Open_Sans_Regular}" Margin="0,0,0,0" HorizontalTextAlignment="Start" VerticalTextAlignment="Start" Grid.Row="0" TextColor="#808080" Font="14" Grid.Column="3" Text = "{Binding Un}" Style ="{StaticResource SmallName}" />
<Label FontFamily="{StaticResource Open_Sans_Regular}" Margin="0,0,5,0" HorizontalTextAlignment="End" VerticalTextAlignment="Start" TextColor="#808080" Grid.Row="0" Font="14" Grid.Column="4" x:Name="totais_linhas" Grid.ColumnSpan="2" Text = "{Binding price, StringFormat= '{0:C2}' }" />
<Label x:Name="desconto_linha" FontFamily="{StaticResource Open_Sans_Regular}" Margin="0,0,0,0" HorizontalTextAlignment="End" VerticalTextAlignment="Start" Grid.Row="1" TextColor="#808080" Font="10" Grid.Column="2" IsVisible="{Binding Selected}" Text = "{Binding Desconto, StringFormat='{0:P}' }" Style ="{StaticResource SmallName}" />
<Label FontFamily="{StaticResource Open_Sans_Regular}" Margin="0,0,5,0" HorizontalTextAlignment="End" Grid.ColumnSpan="2" VerticalTextAlignment="End" TextColor="#808080" Grid.Row="1" Font="10" Grid.Column="4" x:Name="totais" Text = "{Binding Pu, StringFormat= '{0:C2}' }" />
</Grid>
<ViewCell.ContextActions>
<MenuItem Clicked="OnMore" CommandParameter="{Binding .}"
Text="Adicionar" />
<MenuItem Clicked="OnDelete" CommandParameter="{Binding .}"
Text="Apagar" IsDestructive="True" />
<MenuItem Clicked="OnQtd" CommandParameter="{Binding .}"
Text="Apagar" IsDestructive="True" />
</ViewCell.ContextActions>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>