Drag multiple items from WPF listview

前端 未结 3 931
闹比i
闹比i 2021-01-20 18:15

I have a listview that displays files from a directory.
The user can drag each item in the listview to a folder/ the desktop and the associated file is copied there.

3条回答
  •  爱一瞬间的悲伤
    2021-01-20 18:33

     private List _selItems = new List();
        private void FileView_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this._start = e.GetPosition(null);
            _selItems.Clear();
            _selItems.AddRange(FileView.SelectedItems.Cast());
    
        }
    
    
    

    restore on MouseMove

    foreach (object selItem in _selItems)
                {
                    if (!FileView.SelectedItems.Contains(selItem))
                        FileView.SelectedItems.Add(selItem);
                }
    

    提交回复
    热议问题