在UWP XAML(Windows 10)中未触发Drop事件

在UWP XAML(Windows 10)中未触发Drop事件,xaml,windows-10,uwp,Xaml,Windows 10,Uwp,我正在为Windows10开发一个应用程序,我想在两个列表中实现拖放功能。但Windows 10应用程序中没有触发丢弃事件。。 以前,它适用于Windows 8.1。。 以下是我的代码: <ListView Grid.Row="1" x:Name="TasksList" SelectionMode="None" HorizontalAlignment="Stretch" ScrollViewer.VerticalScrollBarVisibility="Hidden" IsIte

我正在为Windows10开发一个应用程序,我想在两个列表中实现拖放功能。但Windows 10应用程序中没有触发丢弃事件。。 以前,它适用于Windows 8.1。。 以下是我的代码:

<ListView Grid.Row="1" x:Name="TasksList" SelectionMode="None" HorizontalAlignment="Stretch" 
    ScrollViewer.VerticalScrollBarVisibility="Hidden" IsItemClickEnabled="True" 
    VerticalAlignment="Stretch" 
    ItemsSource="{Binding Tasks}"  ScrollViewer.VerticalScrollMode="Enabled" 
    CanReorderItems="True"  ShowsScrollingPlaceholders="False"
    DragItemsStarting="GridViewDragItemsStarting"  AllowDrop="True" IsSwipeEnabled="False"
    Drop="GridViewDrop" DragEnter="TasksList_DragEnter" CanDragItems="True"
    ItemContainerStyle="{StaticResource ClientListViewItemStyle}" >
    <ListView.ItemTemplate>
        <DataTemplate>
            <Border BorderThickness="0,0,0,1" BorderBrush="{StaticResource MydesqBorderBrush}" Padding="10">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid Grid.Column="0" Width="80" Height="60" Background="{Binding DueDateIndicatorColor,Converter={StaticResource HexToSolidColorBrushConverter}}" VerticalAlignment="Top" HorizontalAlignment="Center">
                        <Image x:Name="ImgClient" Source="{Binding Client.ClientPictureUrl,Converter={StaticResource ServerUrlConverter}}" Stretch="Fill" Visibility="{Binding Source, Converter={StaticResource NullToInvisibilityConverter}, ElementName=ImgClient}" Width="80" Height="60"/>
                        <Image x:Name="ImgAccount" Source="{Binding ImageUrl}" Width="35" Height="35" Visibility="{Binding Source, Converter={StaticResource NullToInvisibilityConverter}, ElementName=ImgAccount}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                    </Grid>
                    <Grid Grid.Column="1" Margin="10,0,0,0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <TextBlock Text="{Binding TaskTitle}" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="20" Foreground="{Binding TitleColor, Converter={StaticResource HexToSolidColorBrushConverter}}"/>
                        <StackPanel Grid.Row="1" Orientation="Horizontal">
                            <Image  Width="20" Height="20" VerticalAlignment="Center" Source="/Assets/Images/user_gray.png" Margin="0,0,10,0"/>
                            <TextBlock Text="{Binding TaskType}" FontSize="16" VerticalAlignment="Center" Foreground="{Binding SubTitleColor, Converter={StaticResource HexToSolidColorBrushConverter}}" Margin="5,0,0,0"/>
                        </StackPanel>
                        <StackPanel Grid.Row="2" Orientation="Horizontal">
                            <Image Width="20" Height="20" VerticalAlignment="Center" Source="/Assets/Images/calendar_gray.png" Margin="0,0,10,0"/>
                            <TextBlock Text="{Binding DueDate, ConverterParameter=\{0:dd.MM.yyyy\}, Converter={StaticResource DateToStringConverter}}"  FontSize="16" VerticalAlignment="Center" Foreground="{Binding SubTitleColor, Converter={StaticResource HexToSolidColorBrushConverter}}" Margin="5,0,0,0"/>
                        </StackPanel>
                    </Grid>
                </Grid>
            </Border>
        </DataTemplate>
    </ListView.ItemTemplate>
    <Interactivity:Interaction.Behaviors>
        <Core:EventTriggerBehavior EventName="ItemClick">
            <behaviors:NavigateWithEventArgsToPageAction 
            TargetPage="Mydesq.Client.UWP.Views.AddTaskPage"
             EventArgsParameterPath="ClickedItem" />
        </Core:EventTriggerBehavior>
        <Core:EventTriggerBehavior EventName="Drop">
            <Core:InvokeCommandAction Command="{Binding DropTaskCommand}" CommandParameter="{Binding ElementName=TasksList,Path=SelectedItem}"/>
        </Core:EventTriggerBehavior>
    </Interactivity:Interaction.Behaviors>
</ListView>

确保在ListView的DragEnter事件中设置AcceptedOperation属性。例如,像这样:

private void TasksList_DragEnter(object sender, DragEventArgs e)
{
   e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
}

确保在ListView的DragEnter事件中设置AcceptedOperation属性。例如,像这样:

private void TasksList_DragEnter(object sender, DragEventArgs e)
{
   e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
}

我在
MainPage

 AllowDrop="True" 
修复了即使没有
DragEnter
事件也会发生的问题


(我知道您已经拥有此属性(我的答案是针对其他人…)

我在
主页

 AllowDrop="True" 
修复了即使没有
DragEnter
事件也会发生的问题


(我知道您已经拥有此属性(我的答案是针对其他人…)

在“TasksList\u DragEnter”事件中有什么内容?您应该在DragEventArgs上设置AcceptedOperation,例如:e.AcceptedOperation=Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy。谢谢,现在它工作得很好!我把它作为答案贴了出来。。如果您不介意,请接受“任务列表”活动中有什么内容?您应该在DragEventArgs上设置AcceptedOperation,例如:e.AcceptedOperation=Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy。谢谢,现在它工作得很好!我把它作为答案贴了出来。。如果你不介意,请接受。