[英]I can't run applicaton when using '<ViewCell.ContextActions>' on Xamarin Form (PCL)?
严重性代码说明项目文件行抑制状态错误位置37:61。 在xmlns http://schemas.microsoft.com/winfx/2009/xaml Course_3中找不到类型Regerence
<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>
您应该将<ViewCell.ContextActions>
部分移到Grid
控件之外。 它必须是ViewCell
的直接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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.