拖动&;散点视图项目和网格布局的删除失败

本文关键字:网格 布局 失败 删除 项目 视图 amp 拖动 | 更新日期: 2023-09-27 18:28:58

链接到我的应用的图像

我想检测画布上的两张图片是否彼此靠近,然后如果两者都被触摸或靠近,则与图片中嵌入的数据进行一些比较操作。

棕色区域是一个ScatterView,我可以在其中放置图片元素并将其添加到绿色列表框中。

我可以将图片项目直接从蓝色列表框中放到棕色下拉区域。

但是,当我把它们先放在黄色散射视图上时,我就无法离开那里把它们放在棕色散射视图上。

<Grid ShowGridLines="True">
<Grid.RowDefinitions >
  <RowDefinition Height="*" />
  <RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
    <ColumnDefinition></ColumnDefinition>
    <ColumnDefinition></ColumnDefinition>
    <ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>

    <s:ScatterView 
        Grid.Row="0" 
        Grid.Column="0" 
        Grid.ColumnSpan="2" 
        Grid.RowSpan="1" 
        x:Name="ScatterLayer" 
        Background="Yellow" 
        ItemContainerStyle="{StaticResource ScatterItemStyle}" 
        AllowDrop="True"
        ItemTemplate="{StaticResource ImageAndCaptionTemplate}"
        ItemsSource="{Binding ScatterItems}" 
        s:SurfaceDragDrop.Drop="ScatterLayer_Drop" 
        s:SurfaceDragDrop.DragEnter="ScatterLayer_DragEnter" 
        s:SurfaceDragDrop.DragCompleted="ScatterLayer_DragCompleted" >
    </s:ScatterView>
    <s:SurfaceListBox 
        Grid.Row="0" Grid.Column="2"
        AllowDrop="True"
        x:Name="ListBoxVerticalBasket"
        VerticalAlignment="Top"
        Background="GreenYellow"
        ItemsSource="{Binding Path=BasketItems}"
        ItemTemplate="{StaticResource BasketTemplate}" >
        <s:SurfaceListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Vertical" />
            </ItemsPanelTemplate>
        </s:SurfaceListBox.ItemsPanel>
    </s:SurfaceListBox>
    <s:SurfaceListBox 
        Grid.Row="1" 
        Grid.Column="0" 
        Grid.ColumnSpan="2" 
        x:Name="ShoppingList"
        AllowDrop="True" 
        s:SurfaceDragDrop.DragCompleted="OnShoppingListDragCompleted" 
        s:SurfaceDragDrop.DragCanceled="OnShoppingListDragCanceled" 
        PreviewMouseLeftButtonDown="OnShoppingListPreviewMouseLeftButtonDown" 
        PreviewMouseMove="OnShoppingListPreviewMouseMove" 
        PreviewMouseLeftButtonUp="OnShoppingListPreviewMouseLeftButtonUp" 
        ItemsSource="{Binding Path=LibraryItems}" 
        ItemTemplate="{StaticResource ImageAndCaptionTemplate}"
        PreviewTouchDown="OnShoppingListPreviewTouchDown" 
        PreviewTouchMove="OnShoppingListPreviewTouchMove" 
        PreviewTouchUp="OnShoppingListPreviewTouchUp" 
        Background="#FF00BDD8">
        <s:SurfaceListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal" AllowDrop="True"/>
            </ItemsPanelTemplate>
        </s:SurfaceListBox.ItemsPanel>
    </s:SurfaceListBox>
    <s:ScatterView 
        Grid.Column="2" 
        Grid.Row="1" 
        Background="DarkGoldenrod" 
        Width="300" 
        Height="100"
        x:Name="ScatterViewDropArea"
        VerticalAlignment="Top" 
        HorizontalAlignment="Left"
        AllowDrop="True"
        s:SurfaceDragDrop.Drop="ScatterViewDropArea_Drop">
    </s:ScatterView>

拖动&;散点视图项目和网格布局的删除失败

我认为您应该考虑在Surface SDK中使用购物车演示附带的DragDropScatterView,而不是ScatterView