2017-08-12 84 views
0

严重级代码说明项目文件行抑制状态 错误位置37:61。键入Regerence中的xmlns http://schemas.microsoft.com/winfx/2009/xaml Course_3Xamarin Form(PCL)上使用'<ViewCell.ContextActions>'时,我无法运行applicaton?

<ViewCell> 
         <Grid> 
          <Grid.ColumnDefinitions> 
           <ColumnDefinition Width="100"></ColumnDefinition> 
           <ColumnDefinition Width="*"></ColumnDefinition> 
          </Grid.ColumnDefinitions> 

          <Grid Grid.Column="0"> 
           <Image Source="{Binding PhotoUrl}" HeightRequest="70"></Image> 
          </Grid> 

          <StackLayout Grid.Column="1" Padding="5"> 
           <Label Text="{Binding FullName}" FontSize="15" TextColor="Black" Margin="0,5"></Label> 
           <Label Text="{Binding City}" FontSize="10" TextColor="Black" Margin="0,5"></Label> 
           <Label Text="{Binding JobTitle}" FontSize="10" TextColor="#CCCCCC" Margin="0,5"></Label> 
          </StackLayout> 
          <ViewCell.ContextActions> 
           <MenuItem Text="Edit" Command="{Binding Source={x:Reference Root}, Path=BindingContext.EditCommand}" 
              CommandParameter="{Binding}"></MenuItem> 
           <MenuItem Text="Delete" Command="{Binding Source={x:Regerence Root},Path=BindingContext.DeleteCommand}" 
              CommandParameter="{Binding}"></MenuItem> 
          </ViewCell.ContextActions> 
         </Grid> 

        </ViewCell> 
+0

如果它对你有帮助,也请考虑upvoting的答案。谢谢。 –

回答

0

没有找到您要的Grid控制之外将<ViewCell.ContextActions>部分。它需要是ViewCell的直接子女。不知道这是否是您在代码中所做的类型,但将第二个菜单项的{x:Regerence Root}更改为{x:Reference Root}。此外,您的问题可能会从一些编辑中受益,以提高其整体质量。

<ViewCell> 
    <ViewCell.ContextActions> 
     <MenuItem Text="Edit" Command="{Binding Source={x:Reference Root}, Path=BindingContext.EditCommand}" 
        CommandParameter="{Binding}"></MenuItem> 
     <MenuItem Text="Delete" Command="{Binding Source={x:Reference Root},Path=BindingContext.DeleteCommand}" 
        CommandParameter="{Binding}"></MenuItem> 
    </ViewCell.ContextActions> 
    <Grid> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="100"></ColumnDefinition> 
      <ColumnDefinition Width="*"></ColumnDefinition> 
     </Grid.ColumnDefinitions> 

     <Grid Grid.Column="0"> 
      <Image Source="{Binding PhotoUrl}" HeightRequest="70"></Image> 
     </Grid> 

     <StackLayout Grid.Column="1" Padding="5"> 
      <Label Text="{Binding FullName}" FontSize="15" TextColor="Black" Margin="0,5"></Label> 
      <Label Text="{Binding City}" FontSize="10" TextColor="Black" Margin="0,5"></Label> 
      <Label Text="{Binding JobTitle}" FontSize="10" TextColor="#CCCCCC" Margin="0,5"></Label> 
     </StackLayout> 
    </Grid> 

</ViewCell> 
+0

它确定,但ListView项目源绑定是ItemsSource =“{绑定熟人}”=>当我点击菜单项然后该属性为空。 –

相关问题