所以我不知道如何将TopItem中的TargetNullValue正确绑定到我的网格视图的可见性。"quot">
<StackLayout HorizontalOptions="Fill" BackgroundColor="Yellow">
<AbsoluteLayout>
<Button x:Name="exit_button" Image="exit.png" Clicked="Exit_button_Clicked"
AbsoluteLayout.LayoutBounds="1,0,50,50" AbsoluteLayout.LayoutFlags="PositionProportional" />
</AbsoluteLayout>
<swipeCardView:SwipeCardView
x:Name="SwipeCardView"
ItemsSource="{Binding Pictures}"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
BackgroundColor="Red"
Padding="10"
SwipedCommand="{Binding SwipedCommand}"
DraggingCommand="{Binding DraggingCommand}"
Threshold="{Binding Threshold}"
SupportedSwipeDirections="{Binding SupportedDraggingDirections}"
SupportedDraggingDirections="{Binding SupportedDraggingDirections}"
AnimationLength="{Binding AnimationLength}"
>
<swipeCardView:SwipeCardView.TopItem>
<Grid IsVisible="{Binding TopItem , Source={x:Reference SwipeCardView}, TargetNullValue={Binding TopItem}}">
<StackLayout>
<Label Text="Keine Bilder mehr vorhanden" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"
FontSize="Large" FontAttributes="Bold" BackgroundColor="AliceBlue"/>
</StackLayout>
</Grid>
</swipeCardView:SwipeCardView.TopItem>
<swipeCardView:SwipeCardView.ItemTemplate>
<DataTemplate>
<Grid ColumnSpacing="0" RowSpacing="0" BackgroundColor="Wheat">
<Grid.Resources>
<valueconverter:ByteArrayToImageSourceConverter x:Key="SourceConverter" />
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="500" />
</Grid.RowDefinitions>
<Image Source="{Binding Image, Converter={StaticResource SourceConverter}}" Aspect="AspectFit" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"/>
</Grid>
</DataTemplate>
</swipeCardView:SwipeCardView.ItemTemplate>
</swipeCardView:SwipeCardView>
</StackLayout>
</ContentPage>
"quot">
显然有一个错误的绑定,正如我得到的错误:
"Xamarin。表格。网格"无法转换为类型"System"。布尔值'"App1.Models.Pictures"无法转换为类型"System"。布尔型
因此,正如我从TopItem了解到的那样,它变成了null,如果Collectionview或Itemsource为null,则意味着没有项目可以滑动。
我想将绑定设置为顶部项目,这样,如果没有剩余项目,则视图应该是可见的
您可以使用转换器将TopItem转换为布尔值。例如:
public class TopItemToBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
TopItem top= value as TopItem;
if(top == null)
return false;
else
return true;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}