2016-12-26 64 views
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上的菜单项不工作。 我怎么能做这个工作?

+0

怎么样的菜单项iOS上不工作更多DataTemplateSelector? – therealjohn

+0

当我向左拉时没有任何反应。 –

回答

相关问题