1
我有一個列表框Drop事件,包含一些文本值如何確定的DragSource
<ListBox x:Name="DragSource" PreviewMouseMove="DragSource_OnPreviewMouseMove" SelectedValuePath="Content">
<ListBoxItem>first</ListBoxItem>
<ListBoxItem>second</ListBoxItem>
</ListBox>
和事件處理
private void DragSource_OnPreviewMouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed && DragSource.SelectedItem != null)
{
var data = new DataObject(DataFormats.Serializable, DragSource.SelectedItem);
var value = (string)DragSource.SelectedValue;
data.SetData(DataFormats.Text, value);
var de = DragDrop.DoDragDrop(DragSource, data, DragDropEffects.All);
}
}
項目可以刪除我的其他列表框或到其它應用程序一樣Word或Excel。如果DragDrop效果是「Move」,我可以檢測到文本被丟棄(例如在Word中)並刪除ListBoxItem?
我的dragsource有GiveFeedback和QueryContinueDrag事件,在這裏我可以找出現在應用的效果。 QueryContinueDragEventArgs具有可以取消,刪除或繼續的操作。但我只收到Continue事件。 – Steck 2010-11-25 08:22:34