这是一个非常奇怪的问题,我有一个列表视图,我想删除文件,我知道如何获取文件信息等,奇怪的是我实际上它工作正常,但它似乎只是停止。< / p>
我尝试使用listview对象创建一个新项目,allowdrop = true,创建dragenter / drop事件,dragenter包含e.handled = true和e.effects = effects.none。
但事件只是不起作用,我有一个在早期版本的VS上创建的项目,这很好用!!
这是xmal
<Window x:Name="mainWin" x:Class="droptest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style x:Key="ColumnHeaders" TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="Visibility" Value="Collapsed"/>
</Style>
</Window.Resources>
<Grid>
<ListView x:Name="ImageList" AllowDrop="True" HorizontalAlignment="Left" Height="204" Margin="65,69,0,0" VerticalAlignment="Top" Width="374" DragEnter="ImageList_DragEnter" Drop="ImageList_Drop" DragOver="ImageList_DragOver" DragLeave="ImageList_DragLeave">
<ListView.View>
<GridView ColumnHeaderContainerStyle="{StaticResource ColumnHeaders}">
<GridViewColumn/>
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>
这是代码
namespace droptest
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void ImageList_DragEnter(object sender, DragEventArgs e)
{
e.Handled = true;
e.Effects = DragDropEffects.None;
}
private void ImageList_Drop(object sender, DragEventArgs e)
{
}
private void ImageList_PreviewDragOver(object sender, DragEventArgs e)
{
e.Handled = true;
e.Effects = DragDropEffects.None;
}
private void ImageList_PreviewDrop(object sender, DragEventArgs e)
{
}
private void ImageList_DragOver(object sender, DragEventArgs e)
{
e.Handled = true;
e.Effects = DragDropEffects.None;
}
private void ImageList_DragLeave(object sender, DragEventArgs e)
{
e.Handled = true;
e.Effects = DragDropEffects.None;
}
}
}
我不认为我做错了什么,事实上我确信我不是,因为我有它的工作..
任何指针都会非常感激。