Reputation:
I am developing an App For WIndows 10 and I want to Implement the Drag and Drop Frature within Two List. but the Drop Event is Not Firing in Windows 10 App.. Previously it is Woring for Windows 8.1.. Following is My Code:
<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>
Upvotes: 0
Views: 1261
Reputation: 7826
I had similar issue with Grid
in MainPage
AllowDrop="True"
fixed that even without DragEnter
event.
(I know you already have this property (my answer is for others...))
Upvotes: 0
Reputation: 3619
Make sure you set the AcceptedOperation property in the DragEnter event of the ListView. E.g. like this:
private void TasksList_DragEnter(object sender, DragEventArgs e)
{
e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
}
Upvotes: 7