C# 复制将自身重置为无
我在C# 复制将自身重置为无,c#,wpf,scatterview,C#,Wpf,Scatterview,我在散点视图中有一个散点视图项,其操作不由我处理。我在ScatterView中还有一个RichTextBox,属性为AllowDrop=True 默认情况下,只要将ScatterViewItem拖动到RichTextBox中,就会触发RichTextBox的DragEnter事件,这是正确的。我在这里检查了DragDropEffect,它是DragDropEffect.Move。此后,Drop事件将适当触发 我在DragEnter中将DragDropEffect从Move更改为Copy,但Dro
散点视图
中有一个散点视图项
,其操作不由我处理。我在ScatterView中还有一个RichTextBox
,属性为AllowDrop=True
默认情况下,只要将ScatterViewItem拖动到RichTextBox中,就会触发RichTextBox的DragEnter
事件,这是正确的。我在这里检查了DragDropEffect,它是DragDropEffect.Move
。此后,Drop
事件将适当触发
我在DragEnter中将DragDropEffect从Move
更改为Copy
,但Drop事件不再触发。我在DragOver
中再次检查了DragDropEffect,它不知怎么变成了None
。我尝试在DragOver中将其设置为Copy
(再次),但每次在DragOver的下一个触发器上,它都会自动变为None
只有当DragDropEffect设置为All
或Move
时,才会触发拖放事件。如何将其更改为DragDropEffect.Copy
并仍然触发Drop事件?我在设置为DragDropEffect.Copy后,确实设置了e.Handled=true
编辑:
抱歉,我确实操纵了svi的拖放功能。在ScatterView的OnManipulationStarted
中,我得到了svi并调用了svi.BeginDragDrop(svi.DataContext)
。这就是我对svi所做的一切。什么是(DragEventArgs)。AllowedEffects
属性值?只能将(DragEventArgs).Effects
属性设置为(DragEventArgs).AllowedEffects
属性指定的值之一。如果在(DragEventArgs).AllowedEffects
属性枚举中未找到DragDropEffects.Copy
选项,则您将无法使用该函数
您可以在创建数据对象并调用DoDragDrop
时设置该选项:
DragDrop.DoDragDrop(item, dragData, DragDropEffects.All);
更新>>>
正如我所说,通常,在调用DoDragDrop
时,设置允许的DragDropEffects
枚举。。。在看到您调用了surfacedracursor.BeginDragDrop
方法后,我在线查看了MSDN的页面,发现:
public static SurfaceDragCursor BeginDragDrop (
FrameworkElement dragSource,
FrameworkElement draggedElement,
FrameworkElement cursorVisual,
Object data,
IEnumerable<InputDevice> inputDevices,
DragDropEffects allowedEffects
)
public static SurfaceDragCursor BeginDragDrop(
FrameworkElement dragSource,
框架元素DragElement,
FrameworkElement cursorVisual,
对象数据,
i可数输入设备,
DragDropEffects允许的效果
)
我猜这里的最后一个参数是设置
DragDropEffects
允许效果枚举的地方。Hmmm您是否混淆了Effects
和AllowedEffects
?我无法找出允许的效果是什么,在DragEventArgs
的DragEnter
中没有这样的属性。我没有调用DragDrop.DoDragDrop
,而是调用了svi.BeginDragDrop
,它创建了一个SurfaceDragCursor
。我改成了DragDrop。DoDragDrop
和DragEnter
现在甚至不开火。对不起,我对拖放表面项目的了解仍然很薄弱…在DragEnter
中,我检查了(SurfacedDragDropEventArgs).Cursor.AllowedEffects
和它的移动
。是的,我确实把它们弄混了。。。谢谢你指出。。。我现在已经更新了我的答案。另外,如果您的AllowedEffects
仅显示移动
,则您只能移动而不能复制。