Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在列表中拖放,windows 8应用程序?_C#_List_Xaml_Windows 8_Drag And Drop - Fatal编程技术网

C# 在列表中拖放,windows 8应用程序?

C# 在列表中拖放,windows 8应用程序?,c#,list,xaml,windows-8,drag-and-drop,C#,List,Xaml,Windows 8,Drag And Drop,关于如何在windows8c#list(listview,listbox…)中实现拖放,有什么好的示例/教程吗 我想要的是一个可编辑的“Iphone列表”-体验,在这里我可以轻松地重新排列列表中的项目。但是我发现大部分是WinJS示例,我想为win 8提供一个c示例。首先,您必须启用AllowDragDrop属性 然后写3个事件: private void myList_ItemDrag(object sender, ItemDragEventArgs e) {

关于如何在windows8c#list(listview,listbox…)中实现拖放,有什么好的示例/教程吗


我想要的是一个可编辑的“Iphone列表”-体验,在这里我可以轻松地重新排列列表中的项目。但是我发现大部分是WinJS示例,我想为win 8提供一个c示例。首先,您必须启用AllowDragDrop属性

然后写3个事件:

    private void myList_ItemDrag(object sender, ItemDragEventArgs e)
    {
        DoDragDrop(e.Item, DragDropEffects.Link);
    }

    private void myList_DragEnter(object sender, DragEventArgs e)
    {
        e.Effect = DragDropEffects.Link;
    }

    private void myList_DragDrop(object sender, DragEventArgs e)
    {
        // do whatever you need to reorder the list.
    }
要获取已删除项目的索引,请执行以下操作:

Point cp = myList.PointToClient(new Point(e.X, e.Y));
ListViewItem dragToItem = myList.GetItemAt(cp.X, cp.Y);
int dropIndex = dragToItem.Index;

如果需要拖放到ListView或GridView,请在实际项的DataTemplate上触发拖放事件,而不是整个列表。然后您就可以知道它被放在哪个项目上。

首先,我在ListBox中没有找到AllowDragDrop属性。你有什么特别的部件吗?第二,要顺利体验它的所有含义(拖动和滚动,显示对象将降落的位置,等等),需要做很多工作。难道没有任何win8组件、框架或类似的东西吗?这是ListView控件的示例。好的,我看到的ListView和listbox都没有ItemDrag、dragDrop或AllowDragDrop。我遗漏了什么吗?有AllowDrop和Candrag项目