3
我在PCL項目中製作了一個MenuItem動態列表,當列表視圖出現時構建它。上下文操作菜單項在iOS中無法正常工作PCL項目
這是我的XAML:
<ListView x:Name="ListParceiros" RowHeight="60" ItemTapped="Parceiros_Tapped" Style="{StaticResource listViewGlobalStyle}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell Appearing="OnItemAppearing">
<StackLayout Orientation="Horizontal" HorizontalOptions="Fill" BackgroundColor="#fff">
<StackLayout Orientation="Vertical">
<Label Text = "{Binding Nome}" FontSize="24" AbsoluteLayout.LayoutBounds="0.25, 0.25, 400, 40"/>
<Label Text = "{Binding CpfCnpj}" AbsoluteLayout.LayoutBounds="50, 35, 200, 25"/>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
我的CS文件:
private void OnItemAppearing(object sender, EventArgs e)
{
ViewCell theViewCell = (ViewCell)sender;
var item = theViewCell.BindingContext as Pessoa;
theViewCell.ContextActions.Clear();
if (item != null)
{
var pessoaVinculo = _pessoaVinculoRepository.Get(w => w.PessoaId == item.PessoaId && w.NegocioId == App.CurrentUser.NegocioId);
if (pessoaVinculo.NegocioAtivo)
{
var desativarAction = new MenuItem { Text = "Desativar", IsDestructive = true };
desativarAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
desativarAction.Clicked += DesativarParceiro;
var servicoAction = new MenuItem { Text = "Serviços" };
servicoAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
servicoAction.Clicked += CallServicos;
theViewCell.ContextActions.Add(desativarAction);
theViewCell.ContextActions.Add(servicoAction);
}
else
{
var aceitarVinculoAction = new MenuItem { Text = "Aceitar Vinculo" };
aceitarVinculoAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
aceitarVinculoAction.Clicked += AceitarConvite;
theViewCell.ContextActions.Add(aceitarVinculoAction);
}
}
}
當我嘗試訪問菜單項中的Android它的做工精細,但在iOS上的菜單項不工作。 我怎麼能做這個工作?
怎麼樣的菜單項iOS上不工作更多DataTemplateSelector? – therealjohn
當我向左拉時沒有任何反應。 –