Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.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# 复制将自身重置为无_C#_Wpf_Scatterview - Fatal编程技术网

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
仅显示
移动
,则您只能移动而不能复制。